當前位置: 首頁>>代碼示例>>Python>>正文


Python Service.refresh_from_db方法代碼示例

本文整理匯總了Python中hypermap.aggregator.models.Service.refresh_from_db方法的典型用法代碼示例。如果您正苦於以下問題:Python Service.refresh_from_db方法的具體用法?Python Service.refresh_from_db怎麽用?Python Service.refresh_from_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hypermap.aggregator.models.Service的用法示例。


在下文中一共展示了Service.refresh_from_db方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_create_wms_service

# 需要導入模塊: from hypermap.aggregator.models import Service [as 別名]
# 或者: from hypermap.aggregator.models.Service import refresh_from_db [as 別名]
    def test_create_wms_service(self):
        catalog, created = Catalog.objects.get_or_create(
            name="hypermap", slug="hypermap",
            url="search_api"
        )

        # create the service
        service = Service(
            type='OGC:WMS',
            url='http://wms.example.com/ows-invalid?',
            catalog=catalog
        )
        service.save()
        service.refresh_from_db()

        # check service is invalid
        self.assertEqual(service.is_valid, False)

        # check layers number
        self.assertEqual(service.layer_set.all().count(), 3)

        # check all layers are invalid
        for layer in service.layer_set.all():
            self.assertEqual(layer.is_valid, False)
開發者ID:tomkralidis,項目名稱:HHypermap,代碼行數:26,代碼來源:test_wms.py

示例2: test_create_worldmap_service

# 需要導入模塊: from hypermap.aggregator.models import Service [as 別名]
# 或者: from hypermap.aggregator.models.Service import refresh_from_db [as 別名]
    def test_create_worldmap_service(self):

        catalog, created = Catalog.objects.get_or_create(
            name="hypermap", slug="hypermap",
            url="search_api"
        )

        # create the service
        service = Service(
            type='Hypermap:WorldMap',
            url='http://worldmap.harvard.edu/',
            catalog=catalog
        )
        service.save()
        service.refresh_from_db()

        # check title is correct
        self.assertTrue(service.title, 'Harvard WorldMap')

        # check layer number
        self.assertEqual(service.layer_set.all().count(), 10)

        # check deleted layers number
        self.assertEqual(service.layer_set.filter(was_deleted=True).count(), 2)

        # check layer geonode:River_basin_num2 (public)
        layer_0 = service.layer_set.get(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.service.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'):
            date_filtered = layer_with_many_dates.layerdate_set.filter(date=date)
            self.assertEqual(date_filtered.filter(type=DATE_DETECTED).count(), 1)
        # check metadata dates
        for date in ('2011-01-24', '2015-09-30'):
            date_filtered = layer_with_many_dates.layerdate_set.filter(date=date)
            self.assertEqual(
                             date_filtered.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', ):

            date_filtered = layer_with_few_dates.layerdate_set.filter(date=date)
            self.assertEqual(date_filtered.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'):
            date_filtered = layer_with_complex_dates.layerdate_set.filter(date=date)
            self.assertEqual(date_filtered.filter(type=DATE_DETECTED).count(), 1)
        # check metadata dates
        for date in ('-1900-01-01', '-2000-01-01', ):
            date_filtered = layer_with_complex_dates.layerdate_set.filter(date=date)
            self.assertEqual(date_filtered.filter(type=DATE_FROM_METADATA).count(), 1)

        # test dates #4
        layer_with_dates_in_abstract = service.layer_set.get(name='geonode:layer_with_dates_in_abstract')
        # this layer has the following dates
        # in abstract: 1901, 1902
        for date in ('1901-01-01', '1902-01-01'):
            self.assertEqual(
                             layer_with_dates_in_abstract.layerdate_set.filter(
                                date=date).filter(type=DATE_DETECTED).count(), 1)

        # test dates #5
        layer_with_html_tag = service.layer_set.get(name='geonode:layer_with_html_tag')
        self.assertEqual(layer_with_html_tag.layerdate_set.filter(date=date).filter(type=DATE_DETECTED).count(), 0)

        # check layer geonode:layer_with_many_dates (private)
        layer_1 = service.layer_set.get(name='geonode:layer_with_many_dates')
        self.assertFalse(layer_1.is_public)
#.........這裏部分代碼省略.........
開發者ID:tomkralidis,項目名稱:HHypermap,代碼行數:103,代碼來源:test_worldmap.py


注:本文中的hypermap.aggregator.models.Service.refresh_from_db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。