Ejemplo n.º 1
0
    def test_user_cannot_create_organization(self):
        self.client.force_authenticate(self.user)
        data = {
            'abbreviation': 'test',
            'native_name': 'Test organization',
            'name': 'Organization'
        }

        response = self.client.post(OrganizationFactory.get_list_url(), data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 2
0
    def test_staff_user_can_create_organization(self):
        self.client.force_authenticate(self.staff_user)
        data = {
            'abbreviation': 'test',
            'native_name': 'Test organization',
            'name': 'Organization2',
            'customer': None
        }

        response = self.client.post(OrganizationFactory.get_list_url(), data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 3
0
 def test_authenticated_user_can_list_organizations(self):
     self.client.force_authenticate(self.user)
     response = self.client.get(OrganizationFactory.get_list_url())
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 4
0
 def test_anonymous_user_cannot_list_organizations(self):
     response = self.client.get(OrganizationFactory.get_list_url())
     self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)