def test_create_wms_service(self): # create the service service = Service( type='OGC_WMS', url='http://wms.example.com/ows?', ) service.save() # check layer number self.assertEqual(service.layer_set.all().count(), 9) # check layer 0 (public) layer_0 = service.layer_set.all()[0] self.assertEqual(layer_0.name, 'geonode:_30river_project1_1') self.assertEqual(layer_0.title, 'Rivers') self.assertTrue(layer_0.is_public) self.assertEqual(layer_0.keywords.all().count(), 3) self.assertEqual(layer_0.srs.all().count(), 2) self.assertEqual(layer_0.check_set.all().count(), 1) # TODO test layer_0.layerdate_set # test that if creating the service and is already exiting it is not being duplicated # create the service def create_duplicated_service(): duplicated_service = Service( type='OGC_WMS', url='http://wms.example.com/ows?', ) duplicated_service.save() self.assertRaises(Exception, create_duplicated_service)
def setUp(self): signals.post_save.disconnect(layer_post_save, sender=Layer) signals.post_save.disconnect(service_post_save, sender=Service) for s in range(0, SERVICE_NUMBER): service = Service( url='http://%s.fakeurl.com' % s, title='Title %s' % s, type='OGC_WMS', ) service.save() for l in range(0, LAYER_PER_SERVICE_NUMBER): layer = Layer( name='Layer %s, from service %s' % (l, s), bbox_x0=-179, bbox_x1=179, bbox_y0=-89, bbox_y1=89, service=service ) layer.save() service.layer_set.add(layer) for c in range(0, TIMES_TO_CHECK): for s in range(0, SERVICE_NUMBER): service = Service.objects.all()[s] service.check() for layer in service.layer_set.all(): layer.check()
def _insert_or_update(self, resourcetype, source, mode='insert'): ''' Insert or update a record in the repository ''' try: s = Service(type=HYPERMAP_SERVICE_TYPES[resourcetype], url=source) s.save() except Exception as err: raise RuntimeError('HHypermap error: %s' % err) # return a list of ids that were inserted or updated ids = [] for res in Resource.objects.filter(url=source).all(): ids.append({'identifier': res.id_string, 'title': res.title}) return ids
def setUp(self): signals.post_save.disconnect(layer_post_save, sender=Layer) signals.post_save.disconnect(service_post_save, sender=Service) for s in range(0, SERVICE_NUMBER): service = Service( url='http://%s.fakeurl.com' % s, title='Title %s' % s, type='OGC_WMS', ) service.save() for l in range(0, LAYER_PER_SERVICE_NUMBER): layer = Layer(name='Layer %s, from service %s' % (l, s), bbox_x0=-179, bbox_x1=179, bbox_y0=-89, bbox_y1=89, service=service) layer.save() service.layer_set.add(layer) for c in range(0, TIMES_TO_CHECK): for s in range(0, SERVICE_NUMBER): service = Service.objects.all()[s] service.check() for layer in service.layer_set.all(): layer.check()
def test_create_wms_service(self): # create the service service = Service( type='WARPER', url='http://warper.example.com/warper/maps', ) service.save() # check layer number self.assertEqual(service.layer_set.all().count(), 15) # check layer 0 (public) layer_0 = service.layer_set.all()[0] self.assertEqual(layer_0.name, '29568') self.assertEqual(layer_0.title, 'Plate 24: Map bounded by Myrtle Avenue') self.assertTrue(layer_0.is_public) self.assertEqual(layer_0.keywords.all().count(), 0) self.assertEqual(layer_0.srs.all().count(), 3) self.assertEqual(layer_0.check_set.all().count(), 1) self.assertEqual(layer_0.layerdate_set.all()[0].date, '1855-01-01') # a layer with no bbox must be stored with None coordinates layer_no_bbox = service.layer_set.get(name='16239') self.assertEqual(layer_no_bbox.bbox_x0, None) self.assertEqual(layer_no_bbox.bbox_y0, None) self.assertEqual(layer_no_bbox.bbox_x1, None) self.assertEqual(layer_no_bbox.bbox_y1, None) # test that if creating the service and is already exiting it is not being duplicated # create the service def create_duplicated_service(): duplicated_service = Service( type='WARPER', url='http://warper.example.com/warper/maps', ) duplicated_service.save() self.assertRaises(Exception, create_duplicated_service)
def create_warper_service(): service = Service( type='WARPER', url='http://warper.example.com/warper/maps', ) service.save()
def create_wms_service(): service = Service( type='OGC_WMS', url='http://wms.example.com/ows?', ) service.save()
def create_duplicated_service(): duplicated_service = Service( type='WARPER', url='http://warper.example.com/warper/maps', ) duplicated_service.save()
def create_duplicated_service(): duplicated_service = Service( type='OGC_WMS', url='http://wms.example.com/ows?', ) duplicated_service.save()
def create_duplicated_service(): duplicated_service = Service(type='WM', ) duplicated_service.save()
def create_duplicated_service(): duplicated_service = Service( type='WM', ) duplicated_service.save()
def test_create_worldmap_service(self): # create the service service = Service( type='WM', ) service.save() # check url is correct self.assertTrue(service.url, 'http://worldmap.harvard.edu/') # check title is correct self.assertTrue(service.title, 'Harvard WorldMap') # check layer number self.assertEqual(service.layer_set.all().count(), 10) # check layer 0 (public) layer_0 = service.layer_set.all()[0] self.assertEqual(layer_0.name, 'geonode:River_basin_num2') self.assertEqual(layer_0.title, 'China River Basins') self.assertTrue(layer_0.is_public) self.assertEqual(layer_0.layerwm.temporal_extent_start, '1971-02-06') self.assertEqual(layer_0.layerwm.temporal_extent_end, '1974-09-30') self.assertEqual(layer_0.layerwm.category, 'Rivers, Streams, Lakes') self.assertEqual(layer_0.layerwm.username, 'matt') self.assertEqual(layer_0.keywords.all().count(), 4) self.assertEqual(layer_0.srs.all().count(), 3) self.assertEqual(layer_0.check_set.all().count(), 1) # test dates #1 layer_with_many_dates = service.layer_set.get(name='geonode:layer_with_many_dates') # this layer has the following dates # in title: 1999, 1882 # in abstract: 1632, 1661, 1992, 1338 # from metadata: temporal_extent_start: 2011-01-24 # from metadata: temporal_extent_end: 2015-09-30 # check detected dates for date in ('1999-01-01', '1882-01-01', '1632-01-01', '1661-01-01', '1992-01-01'): self.assertEqual(layer_with_many_dates.layerdate_set.filter(date=date).filter(type=DATE_DETECTED).count(), 1) # check metadata dates for date in ('2011-01-24', '2015-09-30'): self.assertEqual(layer_with_many_dates.layerdate_set.filter(date=date).filter(type=DATE_FROM_METADATA).count(), 1) # test dates #2 layer_with_few_dates = service.layer_set.get(name='geonode:layer_with_few_dates') # this layer has the following dates # in title: 1990 # in abstract: 1990, 1996, 2000 # from metadata: temporal_extent_start: 1990-01-01 # from metadata: temporal_extent_end: Date in invalid format # check detected dates for date in ('1990-01-01', '1996-01-01', '2000-01-01'): self.assertEqual(layer_with_few_dates.layerdate_set.filter(date=date).filter(type=DATE_DETECTED).count(), 1) # check metadata dates for date in ('1990-01-01', ): self.assertEqual(layer_with_few_dates.layerdate_set.filter(date=date).filter(type=DATE_FROM_METADATA).count(), 1) # test dates #3 layer_with_complex_dates = service.layer_set.get(name='geonode:layer_with_complex_dates') # this layer has the following dates # in abstract: 1900 BCE, 2000 BCE, Xia dynasty # from metadata: temporal_extent_start: -1900-01-01 # from metadata: temporal_extent_end: -2000-01-01 for date in ('-1900-01-01', '-2000-01-01', '-1600-01-01', '-2100-01-01'): self.assertEqual(layer_with_few_dates.layerdate_set.filter(date=date).filter(type=DATE_DETECTED).count(), 1) # check metadata dates for date in ('-1900-01-01', '-2000-01-01', ): self.assertEqual(layer_with_few_dates.layerdate_set.filter(date=date).filter(type=DATE_FROM_METADATA).count(), 1) # check layer 1 (private) layer_1 = service.layer_set.all()[1] self.assertFalse(layer_1.is_public) # test that if creating the service and is already exiting it is not being duplicated # create the service def create_duplicated_service(): duplicated_service = Service( type='WM', ) duplicated_service.save() self.assertRaises(Exception, create_duplicated_service)
def create_wm_service(): service = Service( type='WM', ) service.save()
def test_create_worldmap_service(self): # create the service service = Service(type='WM', ) service.save() # check url is correct self.assertTrue(service.url, 'http://worldmap.harvard.edu/') # check title is correct self.assertTrue(service.title, 'Harvard WorldMap') # check layer number self.assertEqual(service.layer_set.all().count(), 10) # check layer 0 (public) layer_0 = service.layer_set.all()[0] self.assertEqual(layer_0.name, 'geonode:River_basin_num2') self.assertEqual(layer_0.title, 'China River Basins') self.assertTrue(layer_0.is_public) self.assertEqual(layer_0.layerwm.temporal_extent_start, '1971-02-06') self.assertEqual(layer_0.layerwm.temporal_extent_end, '1974-09-30') self.assertEqual(layer_0.layerwm.category, 'Rivers, Streams, Lakes') self.assertEqual(layer_0.layerwm.username, 'matt') self.assertEqual(layer_0.keywords.all().count(), 4) self.assertEqual(layer_0.srs.all().count(), 3) self.assertEqual(layer_0.check_set.all().count(), 1) # test dates #1 layer_with_many_dates = service.layer_set.get( name='geonode:layer_with_many_dates') # this layer has the following dates # in title: 1999, 1882 # in abstract: 1632, 1661, 1992, 1338 # from metadata: temporal_extent_start: 2011-01-24 # from metadata: temporal_extent_end: 2015-09-30 # check detected dates for date in ('1999-01-01', '1882-01-01', '1632-01-01', '1661-01-01', '1992-01-01'): self.assertEqual( layer_with_many_dates.layerdate_set.filter(date=date).filter( type=DATE_DETECTED).count(), 1) # check metadata dates for date in ('2011-01-24', '2015-09-30'): self.assertEqual( layer_with_many_dates.layerdate_set.filter(date=date).filter( type=DATE_FROM_METADATA).count(), 1) # test dates #2 layer_with_few_dates = service.layer_set.get( name='geonode:layer_with_few_dates') # this layer has the following dates # in title: 1990 # in abstract: 1990, 1996, 2000 # from metadata: temporal_extent_start: 1990-01-01 # from metadata: temporal_extent_end: Date in invalid format # check detected dates for date in ('1990-01-01', '1996-01-01', '2000-01-01'): self.assertEqual( layer_with_few_dates.layerdate_set.filter(date=date).filter( type=DATE_DETECTED).count(), 1) # check metadata dates for date in ('1990-01-01', ): self.assertEqual( layer_with_few_dates.layerdate_set.filter(date=date).filter( type=DATE_FROM_METADATA).count(), 1) # test dates #3 layer_with_complex_dates = service.layer_set.get( name='geonode:layer_with_complex_dates') # this layer has the following dates # in abstract: 1900 BCE, 2000 BCE, Xia dynasty # from metadata: temporal_extent_start: -1900-01-01 # from metadata: temporal_extent_end: -2000-01-01 for date in ('-1900-01-01', '-2000-01-01', '-1600-01-01', '-2100-01-01'): self.assertEqual( layer_with_few_dates.layerdate_set.filter(date=date).filter( type=DATE_DETECTED).count(), 1) # check metadata dates for date in ( '-1900-01-01', '-2000-01-01', ): self.assertEqual( layer_with_few_dates.layerdate_set.filter(date=date).filter( type=DATE_FROM_METADATA).count(), 1) # check layer 1 (private) layer_1 = service.layer_set.all()[1] self.assertFalse(layer_1.is_public) # test that if creating the service and is already exiting it is not being duplicated # create the service def create_duplicated_service(): duplicated_service = Service(type='WM', ) duplicated_service.save() self.assertRaises(Exception, create_duplicated_service)
def create_wm_service(): service = Service(type='WM', ) service.save()