def test_create_user_fail_connection_error(self, m): m.register_uri('POST', 'http://127.0.0.1:5732/api/authentication/signup/', exc=ConnectionError) created, app_user, remote_response = UserInteractor.create_user( **self.valid_data) self.assertFalse(created) self.assertIsNone(app_user)
def test_create_user_success(self, m): fake_uuid = str(uuid.uuid1()) m.register_uri('POST', 'http://127.0.0.1:8000/api/authentication/signup/', json={'uuid': fake_uuid}, status_code=201) created, app_user, remote_response = UserInteractor.create_user( **self.valid_data) self.assertTrue(created)
def test_create_user_fail_404(self, m): m.register_uri( 'POST', 'http://127.0.0.1:8000/random_404/authentication/signup/', json={}, status_code=404) created, app_user, remote_response = UserInteractor.create_user( **self.valid_data) self.assertFalse(created) self.assertIsNone(app_user)
def test_create_user_fail_already_exist(self, m): m.register_uri('POST', 'http://127.0.0.1:8000/api/authentication/signup/', json={ 'username': ['El nombre de usuario ya está en uso.'], 'email': ['El correo ya está en uso.'] }, status_code=400) UserInteractor.create_user(**self.valid_data) created, app_user, remote_response = UserInteractor.create_user( **self.valid_data) self.assertFalse(created) self.assertIsNone(app_user) self.assertEquals( remote_response, { 'username': ['El nombre de usuario ya está en uso.'], 'email': ['El correo ya está en uso.'] })
def test_create_user_fail_without_valid_data(self, m): m.register_uri('POST', 'http://127.0.0.1:8000/api/authentication/signup/', json={}, status_code=400) data = { 'first_name': '', 'last_name': '', 'email': '', 'username': '', 'password': '', 'password_confirmation': '' } created, app_user, remote_response = UserInteractor.create_user(**data) self.assertFalse(created) self.assertIsNone(app_user)