def test_valid_email(self): create_user = CreateUser() result = create_user.mutate('test_user@', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user') result2 = create_user.mutate('test_user@gmail', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user') result3 = create_user.mutate('[email protected]', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user') expected_result = """{ "errors": [ { "message": "['Enter a valid email address.']", "locations": [ { "line": 36, "column": 3 } ], "path": [ "createUser" ] } ], "data": { "createUser": null } }""" self.assertEqual(result, expected_result) self.assertEqual(result2, expected_result) self.assertEqual(result3, expected_result)
def test_password_security(self): create_user = CreateUser() result = create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword', 'P@ssword1', 'test_user') result2 = create_user.mutate('*****@*****.**', 'Test', 'User', 'Password1', 'P@ssword1', 'test_user') result3 = create_user.mutate('*****@*****.**', 'Test', 'User', 'p@ssword1', 'P@ssword1', 'test_user') expected_result = """{ "errors": [ { "message": "Password does not meet security requirements", "locations": [ { "line": 36, "column": 3 } ], "path": [ "createUser" ] } ], "data": { "createUser": null } }""" self.assertEqual(result, expected_result) self.assertEqual(result2, expected_result) self.assertEqual(result3, expected_result)
def test_user_creation(self): create_user = CreateUser() result = create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user2') expected_result = """{ "data": { "createUser": { "user": { "username": "******", "dateJoined": "2019-09-04T03:31:13.380047+00:00" } } } }""" self.assertEqual(result, expected_result)
class Mutation(graphene.ObjectType): update_profile = UpdateProfile.Field() delete_profile = DeleteProfile.Field() create_skill = CreateSkill.Field() update_skill = UpdateSkill.Field() delete_skill = DeleteSkill.Field() create_skillset = CreateSkillset.Field() update_skillset = UpdateSkillset.Field() delete_skillset = DeleteSkillset.Field() create_user = CreateUser.Field() update_user = UpdateUser.Field() delete_user = DeleteUser.Field()
def test_email_already_exists(self): create_user = CreateUser() result = create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user') expected_result = """{ "errors": [ { "message": "User with that email already exists", "locations": [ { "line": 36, "column": 3 } ], "path": [ "createUser" ] } ], "data": { "createUser": null } }""" self.assertEqual(result, expected_result)
def test_valid_password(self): create_user = CreateUser() result = create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword1', 'P@ssword', 'test_user') expected_result = """{ "errors": [ { "message": "Passwords do not match", "locations": [ { "line": 36, "column": 3 } ], "path": [ "createUser" ] } ], "data": { "createUser": null } }""" self.assertEqual(result, expected_result)
def test_username_already_exists(self): create_user = CreateUser() result = create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user') expected_result = """{ "errors": [ { "message": "That username is already taken. Please use another name.", "locations": [ { "line": 36, "column": 3 } ], "path": [ "createUser" ] } ], "data": { "createUser": null } }""" self.assertEqual(result, expected_result)
class Mutation(graphene.ObjectType): signin_user = SigninPayload.Field(required=True) create_user = CreateUser.Field() create_link = CreateLink.Field() create_vote = CreateVote.Field()
class Mutation(graphene.ObjectType): create_user = CreateUser.Field() change_password = ChangePassword.Field()
def setUp(self): create_user = CreateUser() create_user.mutate('*****@*****.**', 'Test', 'User', 'P@ssword1', 'P@ssword1', 'test_user')