Use remove error field, fix tests
This commit is contained in:
parent
1ca982dd24
commit
d46cc7a177
|
|
@ -129,7 +129,6 @@
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "__debug",
|
|
||||||
"description": null,
|
"description": null,
|
||||||
"args": [],
|
"args": [],
|
||||||
"type": {
|
"type": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ describe('Email Verifcation', () => {
|
||||||
Registration: variables => {
|
Registration: variables => {
|
||||||
return {
|
return {
|
||||||
registration: {
|
registration: {
|
||||||
errors: [],
|
|
||||||
message: "success",
|
message: "success",
|
||||||
success: true
|
success: true
|
||||||
}
|
}
|
||||||
|
|
@ -40,12 +39,7 @@ describe('Email Verifcation', () => {
|
||||||
Registration: variables => {
|
Registration: variables => {
|
||||||
return {
|
return {
|
||||||
registration: {
|
registration: {
|
||||||
errors: [
|
message: "invalid_key",
|
||||||
{
|
|
||||||
field: "invalid_key"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
message: "",
|
|
||||||
success: false
|
success: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,12 +62,7 @@ describe('Email Verifcation', () => {
|
||||||
Registration: variables => {
|
Registration: variables => {
|
||||||
return {
|
return {
|
||||||
registration: {
|
registration: {
|
||||||
errors: [
|
message: "unkown_error",
|
||||||
{
|
|
||||||
field: "unkown_error"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
message: "",
|
|
||||||
success: false
|
success: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,12 +84,7 @@ describe('Email Verifcation', () => {
|
||||||
Registration: variables => {
|
Registration: variables => {
|
||||||
return {
|
return {
|
||||||
registration: {
|
registration: {
|
||||||
errors: [
|
message: "no_valid_license",
|
||||||
{
|
|
||||||
field: "no_valid_license"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
message: "",
|
|
||||||
success: false
|
success: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ export default {
|
||||||
this.$router.push('/');
|
this.$router.push('/');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (data.registration.errors[0].field) {
|
switch (data.registration.message) {
|
||||||
case 'invalid_key':
|
case 'invalid_key':
|
||||||
this.errorMessage = 'Der angegebene Verifizierungscode ist falsch oder abgelaufen.';
|
this.errorMessage = 'Der angegebene Verifizierungscode ist falsch oder abgelaufen.';
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ class HepClient:
|
||||||
if 'order_id' in item:
|
if 'order_id' in item:
|
||||||
order_id = item['order_id']
|
order_id = item['order_id']
|
||||||
|
|
||||||
if item['sku'] == settings.MYSKILLBOX_TEACHER_EDITION_ISBN or \
|
if item['sku'] == MYSKILLBOX_TEACHER_EDITION_ISBN or \
|
||||||
item['sku'] == settings.MYSKILLBOX_STUDENT_EDITION_ISBN:
|
item['sku'] == MYSKILLBOX_STUDENT_EDITION_ISBN:
|
||||||
|
|
||||||
product = {
|
product = {
|
||||||
'raw': item,
|
'raw': item,
|
||||||
|
|
@ -171,7 +171,7 @@ class HepClient:
|
||||||
'order_id': order_id
|
'order_id': order_id
|
||||||
}
|
}
|
||||||
|
|
||||||
if item['sku'] == settings.MYSKILLBOX_TEACHER_EDITION_ISBN:
|
if item['sku'] == MYSKILLBOX_TEACHER_EDITION_ISBN:
|
||||||
product['edition'] = TEACHER_KEY
|
product['edition'] = TEACHER_KEY
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
"row_invoiced": 0,
|
"row_invoiced": 0,
|
||||||
"row_total": 44.88,
|
"row_total": 44.88,
|
||||||
"row_total_incl_tax": 46,
|
"row_total_incl_tax": 46,
|
||||||
"sku": "000-4-5678-9012-3",
|
"sku": "978-3-0355-1397-4",
|
||||||
"store_id": 1,
|
"store_id": 1,
|
||||||
"tax_amount": 1.12,
|
"tax_amount": 1.12,
|
||||||
"tax_invoiced": 0,
|
"tax_invoiced": 0,
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
"row_invoiced": 0,
|
"row_invoiced": 0,
|
||||||
"row_total": 44.88,
|
"row_total": 44.88,
|
||||||
"row_total_incl_tax": 46,
|
"row_total_incl_tax": 46,
|
||||||
"sku": "978-3-0355-1450-6",
|
"sku": "978-3-0355-1823-8",
|
||||||
"store_id": 1,
|
"store_id": 1,
|
||||||
"tax_amount": 1.12,
|
"tax_amount": 1.12,
|
||||||
"tax_invoiced": 0,
|
"tax_invoiced": 0,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ from api.schema import schema
|
||||||
from core.factories import UserFactory
|
from core.factories import UserFactory
|
||||||
from core.hep_client import HepClient
|
from core.hep_client import HepClient
|
||||||
from core.tests.mock_hep_data_factory import MockResponse, VALID_TEACHERS_ORDERS
|
from core.tests.mock_hep_data_factory import MockResponse, VALID_TEACHERS_ORDERS
|
||||||
from users.models import License, Role, SchoolClass
|
from users.models import License, Role, SchoolClass, UserRole
|
||||||
|
|
||||||
|
|
||||||
class CouponTests(TestCase):
|
class CouponTests(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ from graphene import relay
|
||||||
|
|
||||||
from core.hep_client import HepClient, HepClientException
|
from core.hep_client import HepClient, HepClientException
|
||||||
from core.models import AdminData
|
from core.models import AdminData
|
||||||
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR
|
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR, NO_VALID_LICENSE
|
||||||
|
|
||||||
|
|
||||||
class Registration(relay.ClientIDMutation):
|
class Registration(relay.ClientIDMutation):
|
||||||
|
|
@ -40,9 +40,9 @@ class Registration(relay.ClientIDMutation):
|
||||||
# double check if user has verified his email. If the "confirmation" field is present, the email address
|
# double check if user has verified his email. If the "confirmation" field is present, the email address
|
||||||
# is not verified. Note that the user should not be able to see this page without verified email.
|
# is not verified. Note that the user should not be able to see this page without verified email.
|
||||||
if 'confirmation' in user_data:
|
if 'confirmation' in user_data:
|
||||||
return cls.return_registration_msg('invalid_key')
|
return cls.return_fail_registration_msg('invalid_key')
|
||||||
except HepClientException:
|
except HepClientException:
|
||||||
return cls.return_registration_msg('unknown_error')
|
return cls.return_fail_registration_msg('unknown_error')
|
||||||
|
|
||||||
user, status_msg = handle_user_and_verify_products(user_data)
|
user, status_msg = handle_user_and_verify_products(user_data)
|
||||||
|
|
||||||
|
|
@ -50,17 +50,19 @@ class Registration(relay.ClientIDMutation):
|
||||||
login(info.context, user)
|
login(info.context, user)
|
||||||
|
|
||||||
if status_msg:
|
if status_msg:
|
||||||
return cls.return_registration_msg(status_msg)
|
if status_msg == NO_VALID_LICENSE:
|
||||||
|
return cls(success=True, message=NO_VALID_LICENSE)
|
||||||
|
else:
|
||||||
|
return cls.return_fail_registration_msg(status_msg)
|
||||||
|
|
||||||
return cls(success=True, message='success')
|
return cls(success=True, message='success')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def return_registration_msg(cls, message):
|
def return_fail_registration_msg(cls, message):
|
||||||
# even if the user has no valid license on the hep server treat it like a success as registration has succeeded
|
|
||||||
if message == UNKNOWN_ERROR:
|
if message == UNKNOWN_ERROR:
|
||||||
raise Exception(message)
|
raise Exception(message)
|
||||||
|
|
||||||
return cls(success=True, message=message)
|
return cls(success=False, message=message)
|
||||||
|
|
||||||
|
|
||||||
class RegistrationMutations:
|
class RegistrationMutations:
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class RegistrationTests(TestCase):
|
||||||
|
|
||||||
result = self.make_register_mutation('CONFIRMATION_KEY', 1)
|
result = self.make_register_mutation('CONFIRMATION_KEY', 1)
|
||||||
|
|
||||||
self.assertTrue(result.get('data').get('registration').get('success'))
|
self.assertFalse(result.get('data').get('registration').get('success'))
|
||||||
self.assertEqual(result.get('data').get('registration').get('message'), 'invalid_key')
|
self.assertEqual(result.get('data').get('registration').get('message'), 'invalid_key')
|
||||||
|
|
||||||
@patch.object(HepClient, '_customer_orders', return_value=VALID_TEACHERS_ORDERS)
|
@patch.object(HepClient, '_customer_orders', return_value=VALID_TEACHERS_ORDERS)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue