Example #1
0
    def test_has_locations_attribute(self):
        service = ServiceBuilder(self.organization).build()
        validate_save_and_reload(service)

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

        service_at_location = ServiceAtLocation(service=service, location=location)
        validate_save_and_reload(service_at_location)

        self.assertEqual(service.locations.first(), location)
Example #2
0
def build_service_at_location_active_record(record):
    active_record = ServiceAtLocation()
    active_record.service_id = record.id
    active_record.location_id = record.site_id
    return active_record
Example #3
0
 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()
Example #4
0
 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)
Example #5
0
def add_service_to_location(service, location):
    ServiceAtLocation(service=service, location=location).save()