Ejemplo n.º 1
0
 def test_cannot_delete(self):
     location = LocationBuilder(self.organization).build()
     location.save()
     url = '/v1/locations/{0}/'.format(location.pk)
     response = self.client.delete(url)
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
Ejemplo n.º 2
0
 def test_cannot_put_to_organization(self):
     location = LocationBuilder(self.organization).build()
     location.save()
     url = '/v1/organizations/{0}/locations/{1}/'.format(
         self.organization_id, location.pk)
     response = self.client.put(url, self.data)
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
Ejemplo n.º 3
0
 def test_can_get_one_location(self):
     location = LocationBuilder(
         self.organization).with_description('The description').build()
     location.save()
     url = '/v1/locations/{0}/'.format(location.pk)
     response = self.client.get(url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.json()['description'], 'The description')
Ejemplo n.º 4
0
class TestServiceAtLocationModel(TestCase):
    def setUp(self):
        self.organization = OrganizationBuilder().build()
        self.organization.save()

        self.service = ServiceBuilder(self.organization).build()
        self.service.save()

        self.location = LocationBuilder(self.organization).build()
        self.location.save()

    def test_has_service_field(self):
        service_at_location = ServiceAtLocation(service=self.service,
                                                location=self.location)
        service_location_from_db = validate_save_and_reload(
            service_at_location)
        self.assertEqual(service_location_from_db.service, self.service)

    def test_service_cannot_be_none(self):
        service_at_location = ServiceAtLocation(service=None,
                                                location=self.location)
        with self.assertRaises(exceptions.ValidationError):
            service_at_location.full_clean()

    def test_has_location_field(self):
        service_at_location = ServiceAtLocation(service=self.service,
                                                location=self.location)
        service_location_from_db = validate_save_and_reload(
            service_at_location)
        self.assertEqual(service_location_from_db.location, self.location)

    def test_location_cannot_be_none(self):
        service_at_location = ServiceAtLocation(service=self.service,
                                                location=None)
        with self.assertRaises(exceptions.ValidationError):
            service_at_location.full_clean()