Use remove error field, fix tests
This commit is contained in:
parent
1ca982dd24
commit
d46cc7a177
|
|
@ -129,7 +129,6 @@
|
|||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "__debug",
|
||||
"description": null,
|
||||
"args": [],
|
||||
"type": {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ describe('Email Verifcation', () => {
|
|||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [],
|
||||
message: "success",
|
||||
success: true
|
||||
}
|
||||
|
|
@ -40,12 +39,7 @@ describe('Email Verifcation', () => {
|
|||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "invalid_key"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
message: "invalid_key",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
|
|
@ -68,12 +62,7 @@ describe('Email Verifcation', () => {
|
|||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "unkown_error"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
message: "unkown_error",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
|
|
@ -95,12 +84,7 @@ describe('Email Verifcation', () => {
|
|||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "no_valid_license"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
message: "no_valid_license",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export default {
|
|||
this.$router.push('/');
|
||||
}
|
||||
} else {
|
||||
switch (data.registration.errors[0].field) {
|
||||
switch (data.registration.message) {
|
||||
case 'invalid_key':
|
||||
this.errorMessage = 'Der angegebene Verifizierungscode ist falsch oder abgelaufen.';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -161,8 +161,8 @@ class HepClient:
|
|||
if 'order_id' in item:
|
||||
order_id = item['order_id']
|
||||
|
||||
if item['sku'] == settings.MYSKILLBOX_TEACHER_EDITION_ISBN or \
|
||||
item['sku'] == settings.MYSKILLBOX_STUDENT_EDITION_ISBN:
|
||||
if item['sku'] == MYSKILLBOX_TEACHER_EDITION_ISBN or \
|
||||
item['sku'] == MYSKILLBOX_STUDENT_EDITION_ISBN:
|
||||
|
||||
product = {
|
||||
'raw': item,
|
||||
|
|
@ -171,7 +171,7 @@ class HepClient:
|
|||
'order_id': order_id
|
||||
}
|
||||
|
||||
if item['sku'] == settings.MYSKILLBOX_TEACHER_EDITION_ISBN:
|
||||
if item['sku'] == MYSKILLBOX_TEACHER_EDITION_ISBN:
|
||||
product['edition'] = TEACHER_KEY
|
||||
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
"row_invoiced": 0,
|
||||
"row_total": 44.88,
|
||||
"row_total_incl_tax": 46,
|
||||
"sku": "000-4-5678-9012-3",
|
||||
"sku": "978-3-0355-1397-4",
|
||||
"store_id": 1,
|
||||
"tax_amount": 1.12,
|
||||
"tax_invoiced": 0,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
"row_invoiced": 0,
|
||||
"row_total": 44.88,
|
||||
"row_total_incl_tax": 46,
|
||||
"sku": "978-3-0355-1450-6",
|
||||
"sku": "978-3-0355-1823-8",
|
||||
"store_id": 1,
|
||||
"tax_amount": 1.12,
|
||||
"tax_invoiced": 0,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from api.schema import schema
|
|||
from core.factories import UserFactory
|
||||
from core.hep_client import HepClient
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from graphene import relay
|
|||
|
||||
from core.hep_client import HepClient, HepClientException
|
||||
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):
|
||||
|
|
@ -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
|
||||
# is not verified. Note that the user should not be able to see this page without verified email.
|
||||
if 'confirmation' in user_data:
|
||||
return cls.return_registration_msg('invalid_key')
|
||||
return cls.return_fail_registration_msg('invalid_key')
|
||||
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)
|
||||
|
||||
|
|
@ -50,17 +50,19 @@ class Registration(relay.ClientIDMutation):
|
|||
login(info.context, user)
|
||||
|
||||
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')
|
||||
|
||||
@classmethod
|
||||
def return_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
|
||||
def return_fail_registration_msg(cls, message):
|
||||
if message == UNKNOWN_ERROR:
|
||||
raise Exception(message)
|
||||
|
||||
return cls(success=True, message=message)
|
||||
return cls(success=False, message=message)
|
||||
|
||||
|
||||
class RegistrationMutations:
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class RegistrationTests(TestCase):
|
|||
|
||||
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')
|
||||
|
||||
@patch.object(HepClient, '_customer_orders', return_value=VALID_TEACHERS_ORDERS)
|
||||
|
|
|
|||
Loading…
Reference in New Issue