Ejemplo n.º 1
0
    def test_staff_can_delete_organization(self):
        self.client.force_authenticate(self.staff_user)
        organization = OrganizationFactory()

        response = self.client.delete(
            OrganizationFactory.get_url(organization))
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
Ejemplo n.º 2
0
    def test_user_cannot_delete_organization(self):
        self.client.force_authenticate(self.user)
        organization = OrganizationFactory()

        response = self.client.delete(
            OrganizationFactory.get_url(organization))
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 3
0
 def test_user_can_create_organization_user(self):
     organization = OrganizationFactory()
     self.client.force_authenticate(self.user)
     data = {
         'user': structure_factories.UserFactory.get_url(self.user),
         'organization': OrganizationFactory.get_url(organization)
     }
     response = self.client.post(OrganizationUserFactory.get_list_url(),
                                 data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 4
0
    def test_after_removing_organization_customer_still_exist(self):
        self.client.force_authenticate(self.staff_user)
        organization = OrganizationFactory()

        response = self.client.delete(
            OrganizationFactory.get_url(organization))
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

        customer = structure_models.Customer.objects.filter(
            uuid=organization.customer.uuid)
        self.assertTrue(customer.exists())
Ejemplo n.º 5
0
    def test_staff_user_can_update_organization(self):
        self.client.force_authenticate(self.staff_user)
        organization = OrganizationFactory()
        data = {
            'abbreviation': 'test',
            'native_name': 'Test organization',
            'name': 'Organization2',
            'customer': None
        }

        response = self.client.put(OrganizationFactory.get_url(organization),
                                   data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 6
0
    def test_user_can_access_organization(self):
        organization = OrganizationFactory()
        self.client.force_authenticate(self.user)

        response = self.client.get(OrganizationFactory.get_url(organization))
        self.assertEqual(response.status_code, status.HTTP_200_OK)