Exemplo n.º 1
0
    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'])
Exemplo n.º 2
0
    def test_create_organization_new_default_org(self):
        Organization.objects.filter(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'])
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 def test_create_organization_no_coreuser(self):
     response = auth_pipeline.create_organization(core_user=None,
                                                  is_new_core_user=True)
     self.assertIsNone(response)