def test_create_organization_new_username_org(self): coreuser = factories.CoreUser(first_name='John', last_name='Lennon') response = auth_pipeline.create_organization(core_user=coreuser, is_new_core_user=True) self.assertIn('is_new_org', response) self.assertTrue(response['is_new_org']) self.assertIn('organization', response) self.assertTrue(isinstance(response['organization'], Organization)) self.assertEqual(response['organization'].name, coreuser.username) coreuser.refresh_from_db() self.assertEqual(coreuser.organization, response['organization'])
def test_create_organization_new_default_org(self): Organization.objects.get(name=settings.DEFAULT_ORG).delete() coreuser = factories.CoreUser(first_name='John', last_name='Lennon', organization=None) response = auth_pipeline.create_organization(core_user=coreuser, is_new_core_user=True) self.assertIn('is_new_org', response) self.assertTrue(response['is_new_org']) self.assertIn('organization', response) self.assertTrue(isinstance(response['organization'], Organization)) self.assertEqual(response['organization'].name, settings.DEFAULT_ORG) coreuser.refresh_from_db() self.assertEqual(coreuser.organization, response['organization'])
def test_create_organization_no_is_new_core_user(self): coreuser = factories.CoreUser(first_name='John', last_name='Lennon') response = auth_pipeline.create_organization(core_user=coreuser) self.assertIsNone(response)
def test_create_organization_no_coreuser(self): response = auth_pipeline.create_organization(core_user=None, is_new_core_user=True) self.assertIsNone(response)