def get_validator(location_types, locations, old_collection=None): validator = LocationTreeValidator( [LocationTypeStub(*loc_type) for loc_type in location_types], [MockLocationStub(*loc) for loc in locations], old_collection=old_collection ) return validator
def bulk_update_locations(self, types, locations): importer = NewLocationImporter( self.domain.name, [LocationTypeStub(*loc_type) for loc_type in types], [LocationStub(*loc) for loc in locations], ) result = importer.run() return result
def make_collection(types, locations): types = [LocationTypeStub(*loc_type) for loc_type in types] locations = [LocationStub(*loc) for loc in locations] return MockCollection( types=types, locations=locations, locations_by_id={l.location_id: l for l in locations}, locations_by_site_code={l.site_code: l for l in locations}, custom_data_validator=None, domain_name='location-bulk-management', )
def make_collection(types, locations): types = [LocationTypeStub(*loc_type) for loc_type in types] locations = [LocationStub(*loc) for loc in locations] def locations_by_parent_code(): locs_by_parent = defaultdict(list) for loc in locations: locs_by_parent[loc.parent_code].append(loc) return locs_by_parent return MockCollection( types=types, locations=locations, locations_by_id={l.location_id: l for l in locations}, locations_by_site_code={l.site_code: l for l in locations}, locations_by_parent_code=locations_by_parent_code(), custom_data_validator=None, domain_name='location-bulk-management', )