def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        self.clean()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Interface, LayerWMS, LayerWMTS, Role, RestrictionArea

        main = Interface(name=u"desktop")
        role = Role(name=u"__test_role")
        user = User(username=u"__test_user", password=u"__test_user", role=role)
        user.email = "*****@*****.**"
        ogc_server_internal, _ = create_default_ogcserver()

        layer_wms = LayerWMS(name=u"__test_layer_wms", public=True)
        layer_wms.layer = "__test_public_layer"
        layer_wms.interfaces = [main]
        layer_wms.ogc_server = ogc_server_internal

        layer_wms_private = LayerWMS(name=u"__test_layer_wms_private", public=True)
        layer_wms_private.layer = "__test_private_layer"
        layer_wms_private.public = False
        layer_wms_private.interfaces = [main]
        layer_wms_private.ogc_server = ogc_server_internal

        layer_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_wmts_private = LayerWMTS(name=u"__test_layer_wmts_private", public=True)
        layer_wmts_private.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts_private.layer = "map"
        layer_wmts_private.public = False
        layer_wmts_private.interfaces = [main]

        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [layer_wms, layer_wms_private, layer_wmts, layer_wmts_private]

        theme = Theme(name=u"__test_theme")
        theme.interfaces = [main]
        theme.children = [layer_group]

        restriction_area = RestrictionArea(
            name=u"__test_ra1", layers=[layer_wms_private, layer_wmts_private], roles=[role]
        )

        DBSession.add_all([theme, restriction_area, user])

        transaction.commit()
示例#2
0
def layer_wmts_test_data(dbsession):
    from c2cgeoportal_commons.models.main import \
        LayerWMTS, RestrictionArea, Interface

    dbsession.begin_nested()

    restrictionareas = [RestrictionArea(name='restrictionarea_{}'.format(i))
                        for i in range(0, 5)]

    interfaces = [Interface(name) for name in ['desktop', 'mobile', 'edit', 'routing']]

    layers = []
    for i in range(0, 25):
        name = 'layer_wmts_{}'.format(i)
        layer = LayerWMTS(name=name)
        layer.layer = name
        layer.url = 'https://server{}.net/wmts'.format(i)
        layer.restrictionareas = [restrictionareas[i % 5],
                                  restrictionareas[(i + 2) % 5]]
        if i % 10 != 1:
            layer.interfaces = [interfaces[i % 4], interfaces[(i + 2) % 4]]
        layer.public = 1 == i % 2
        layer.image_type = 'image/jpeg'
        dbsession.add(layer)
        layers.append(layer)

    dbsession.flush()
    yield {
        'layers': layers,
        'restrictionareas': restrictionareas,
        'interfaces': interfaces
    }

    dbsession.rollback()
示例#3
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import (
            Dimension,
            Interface,
            LayerGroup,
            LayerWMS,
            LayerWMTS,
            Theme,
        )

        ogc_server = create_default_ogcserver()
        main = Interface(name="main")

        layer_wms_1 = LayerWMS(name="__test_layer_wms_1", public=True)
        layer_wms_1.layer = "testpoint_unprotected"
        layer_wms_1.interfaces = [main]
        layer_wms_1.ogc_server = ogc_server
        Dimension("A", "a", layer_wms_1)

        layer_wms_2 = LayerWMS(name="__test_layer_wms_2", public=True)
        layer_wms_2.layer = "testpoint_unprotected"
        layer_wms_2.interfaces = [main]
        layer_wms_2.ogc_server = ogc_server
        Dimension("A", "b", layer_wms_2)

        layer_wms_3 = LayerWMS(name="__test_layer_wms_3", public=True)
        layer_wms_3.layer = "testpoint_unprotected"
        layer_wms_3.interfaces = [main]
        layer_wms_3.ogc_server = ogc_server
        Dimension("A", None, layer_wms_3)

        layer_wms_4 = LayerWMS(name="__test_layer_wms_4", public=True)
        layer_wms_4.layer = "testpoint_unprotected"
        layer_wms_4.interfaces = [main]
        layer_wms_4.ogc_server = ogc_server
        Dimension("A", "a", layer_wms_4)

        layer_wms_5 = LayerWMS(name="__test_layer_wms_5", public=True)
        layer_wms_5.layer = "testpoint_unprotected"
        layer_wms_5.interfaces = [main]
        layer_wms_5.ogc_server = ogc_server
        Dimension("B", "b", layer_wms_5)

        layer_wms_6 = LayerWMS(name="__test_layer_wms_6", public=True)
        layer_wms_6.layer = "testpoint_unprotected"
        layer_wms_6.interfaces = [main]
        layer_wms_6.ogc_server = ogc_server
        Dimension("FILTER", "countries:\"name\" IN ( 'Germany' , 'Italy' )",
                  layer_wms_6)

        layer_wms_7 = LayerWMS(name="__test_layer_wms_7", public=True)
        layer_wms_7.layer = "testpoint_unprotected"
        layer_wms_7.interfaces = [main]
        layer_wms_7.ogc_server = ogc_server
        Dimension("FLOOR", None, layer_wms_7, "floor")

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://tilecloudchain/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]
        Dimension("B", "b", layer_wmts)

        layer_wmts_2 = LayerWMTS(name="__test_layer_wmts_2", public=True)
        layer_wmts_2.url = "http://tilecloudchain/1.0.0/WMTSCapabilities.xml"
        layer_wmts_2.layer = "map"
        layer_wmts_2.interfaces = [main]
        Dimension("FILTER", "countries:\"name\" IN ( 'Germany' , 'Italy' )",
                  layer_wmts_2)

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_wms_1, layer_wmts, layer_wmts_2]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_wms_1, layer_wms_2]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wms_1, layer_wms_3]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_wms_1, layer_wms_4]

        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_wms_1, layer_wms_5, layer_wms_6]

        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_wms_3]

        layer_group_7 = LayerGroup(name="__test_layer_group_7")
        layer_group_7.children = [layer_wms_7]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1,
            layer_group_2,
            layer_group_3,
            layer_group_4,
            layer_group_5,
            layer_group_6,
            layer_group_7,
        ]

        DBSession.add(theme)

        transaction.commit()
示例#4
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        self.clean()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Interface, LayerWMS, LayerWMTS, Role, RestrictionArea

        main = Interface(name=u"desktop")
        role = Role(name=u"__test_role")
        user = User(username=u"__test_user",
                    password=u"__test_user",
                    role=role)
        user.email = "*****@*****.**"
        ogc_server_internal, _ = create_default_ogcserver()

        layer_wms = LayerWMS(name=u"__test_layer_wms", public=True)
        layer_wms.layer = "__test_public_layer"
        layer_wms.interfaces = [main]
        layer_wms.ogc_server = ogc_server_internal

        layer_wms_private = LayerWMS(name=u"__test_layer_wms_private",
                                     public=True)
        layer_wms_private.layer = "__test_private_layer"
        layer_wms_private.public = False
        layer_wms_private.interfaces = [main]
        layer_wms_private.ogc_server = ogc_server_internal

        layer_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_wmts_private = LayerWMTS(name=u"__test_layer_wmts_private",
                                       public=True)
        layer_wmts_private.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts_private.layer = "map"
        layer_wmts_private.public = False
        layer_wmts_private.interfaces = [main]

        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [
            layer_wms, layer_wms_private, layer_wmts, layer_wmts_private
        ]

        theme = Theme(name=u"__test_theme")
        theme.interfaces = [main]
        theme.children = [layer_group]

        restriction_area = RestrictionArea(
            name=u"__test_ra1",
            layers=[layer_wms_private, layer_wmts_private],
            roles=[role])

        DBSession.add_all([theme, restriction_area, user])

        transaction.commit()
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Theme, LayerGroup, Interface, OGCServer, LayerWMS, LayerWMTS

        main = Interface(name="main")

        ogc_server_internal = create_default_ogcserver()
        ogc_server_external = OGCServer(name="__test_ogc_server_external", url="http://wms.geo.admin.ch/", image_type="image/jpeg")

        layer_internal_wms = LayerWMS(name="__test_layer_internal_wms", public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main]
        layer_internal_wms.ogc_server = ogc_server_internal

        layer_external_wms = LayerWMS(name="__test_layer_external_wms", layer="ch.swisstopo.dreiecksvermaschung", public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.ogc_server = ogc_server_external

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_internal_wms]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_external_wms]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wmts]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_group_1, layer_group_2]

        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_group_1, layer_group_3]

        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_internal_wms]

        layer_group_7 = LayerGroup(name="__test_layer_group_7")
        layer_group_7.children = [layer_group_1, layer_group_6]

        layer_group_8 = LayerGroup(name="__test_layer_group_8")
        layer_group_8.children = [layer_group_2, layer_group_6]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1, layer_group_2, layer_group_3,
            layer_group_4, layer_group_5,
            layer_group_7, layer_group_8,
        ]

        DBSession.add(theme)

        transaction.commit()
def edit_url_test_data(dbsession, transact):
    del transact

    from c2cgeoportal_commons.models.main import \
        LayerWMTS, RestrictionArea, Interface, Role, \
        LayerWMS, LayerGroup, Theme, OGCServer, Functionality

    restrictionareas = [
        RestrictionArea(name='restrictionarea_{}'.format(i))
        for i in range(0, 5)
    ]
    functionalities = {}
    for name in ('default_basemap', 'location'):
        functionalities[name] = []
        for v in range(0, 4):
            functionality = Functionality(name=name,
                                          value='value_{}'.format(v))
            dbsession.add(functionality)
            functionalities[name].append(functionality)

    interfaces = [
        Interface(name) for name in ['desktop', 'mobile', 'edit', 'routing']
    ]
    ogc_server = OGCServer(name='ogc_server')

    layers_wmts = []
    for i in range(0, 5):
        name = 'layer_wmts_{}'.format(i)
        layer_wmts = LayerWMTS(name=name)
        layer_wmts.layer = name
        layer_wmts.url = 'https://server{}.net/wmts'.format(i)
        layer_wmts.restrictionareas = [
            restrictionareas[i % 5], restrictionareas[(i + 2) % 5]
        ]
        if i % 10 != 1:
            layer_wmts.interfaces = [
                interfaces[i % 4], interfaces[(i + 2) % 4]
            ]
        layer_wmts.public = 1 == i % 2
        layer_wmts.image_type = 'image/jpeg'
        dbsession.add(layer_wmts)
        layers_wmts.append(layer_wmts)

    layers_wms = []
    for i in range(0, 5):
        layer_wms = LayerWMS(name='layer_wms_{}'.format(i))
        layer_wms.layer = 'wms_layer_{}'.format(i)
        layer_wms.ogc_server = ogc_server
        layers_wms.append(layer_wms)
        dbsession.add(layer_wms)
        layers_wms.append(layer_wms)

    roles = []
    for i in range(0, 5):
        role = Role('secretary_' + str(i))
        role.functionalities = [
            functionalities['default_basemap'][0],
            functionalities['location'][0], functionalities['location'][1]
        ]
        role.restrictionareas = [restrictionareas[0], restrictionareas[1]]
        dbsession.add(role)
        roles.append(role)

    dbsession.flush()

    group = LayerGroup(name='groups')
    dbsession.add(group)
    theme = Theme(name='theme')
    dbsession.add(theme)

    dbsession.flush()

    yield {
        'ogc_server': ogc_server,
        'layers_wmts': layers_wmts,
        'layers_wms': layers_wms,
        'restrictionareas': restrictionareas,
        'interfaces': interfaces,
        'themes': [theme],
        'group': group,
        'roles': roles
    }
示例#7
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Functionality, Interface, OGCServer, LayerWMS, LayerWMTS, \
            Metadata, Dimension, OGCSERVER_AUTH_NOAUTH

        main = Interface(name="desktop")
        mobile = Interface(name="mobile")
        min_levels = Interface(name="min_levels")

        ogc_server_internal, _ = create_default_ogcserver()
        ogc_server_external = OGCServer(name="__test_ogc_server_chtopo",
                                        url="http://wms.geo.admin.ch/",
                                        image_type="image/jpeg",
                                        auth=OGCSERVER_AUTH_NOAUTH)
        ogc_server_external.wfs_support = False

        layer_internal_wms = LayerWMS(name="__test_layer_internal_wms",
                                      public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main, min_levels]
        layer_internal_wms.metadatas = [Metadata("test", "internal_wms")]
        layer_internal_wms.ogc_server = ogc_server_internal

        layer_external_wms = LayerWMS(name="__test_layer_external_wms",
                                      layer="ch.swisstopo.dreiecksvermaschung",
                                      public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.metadatas = [Metadata("test", "external_wms")]
        layer_external_wms.ogc_server = ogc_server_external

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main, mobile]
        layer_wmts.metadatas = [Metadata("test", "wmts")]
        layer_wmts.dimensions = [Dimension("year", "2015")]

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [
            layer_internal_wms, layer_external_wms, layer_wmts
        ]
        layer_group_1.metadatas = [Metadata("test", "group_1")]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [
            layer_wmts, layer_internal_wms, layer_external_wms
        ]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [
            layer_wmts, layer_internal_wms, layer_external_wms
        ]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_group_2]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main, mobile]
        theme.metadatas = [Metadata("test", "theme")]
        theme.children = [layer_group_1, layer_group_2]
        theme_layer = Theme(name="__test_theme_layer")
        theme_layer.interfaces = [min_levels]
        theme_layer.children = [layer_internal_wms]

        functionality1 = Functionality(name="test_name", value="test_value_1")
        functionality2 = Functionality(name="test_name", value="test_value_2")
        theme.functionalities = [functionality1, functionality2]

        DBSession.add_all([theme, theme_layer])

        transaction.commit()
示例#8
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Theme, LayerGroup, Interface, LayerWMS, LayerWMTS

        PointTest.__table__.create(bind=DBSession.bind, checkfirst=True)

        main = Interface(name="desktop")
        ogc_server = create_default_ogcserver()

        layer_wms_1 = LayerWMS(name="__test_layer_time_1", public=True)
        layer_wms_1.layer = "test_wmstime"
        layer_wms_1.time_mode = "value"
        layer_wms_1.interfaces = [main]
        layer_wms_1.ogc_server = ogc_server

        layer_wms_2 = LayerWMS(name="__test_layer_time_2", public=True)
        layer_wms_2.layer = "test_wmstime2"
        layer_wms_2.time_mode = "value"
        layer_wms_2.interfaces = [main]
        layer_wms_2.ogc_server = ogc_server

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_wms_group = LayerWMS(name="__test_layer_time_group", public=True)
        layer_wms_group.layer = "test_wmstimegroup"
        layer_wms_group.time_mode = "range"
        layer_wms_group.time_widget = "datepicker"
        layer_wms_group.interfaces = [main]
        layer_wms_group.ogc_server = ogc_server

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_wms_1, layer_wms_2]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_wms_1]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wms_1, layer_wms_2, layer_wms_group]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_wms_group]

        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_wms_1, layer_wms_2]

        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_wms_1, layer_wms_2, layer_wmts]

        layer_group_7 = LayerGroup(name="__test_layer_group_7")
        layer_group_7.children = [layer_wms_1]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1,
            layer_group_2,
            layer_group_3,
            layer_group_4,
            layer_group_5,
            layer_group_6,
            layer_group_7,
        ]

        DBSession.add_all([theme])

        transaction.commit()
示例#9
0
def layertree_test_data(dbsession, transact):
    del transact

    from c2cgeoportal_commons.models.main import (
        Interface,
        LayerGroup,
        LayergroupTreeitem,
        LayerWMS,
        LayerWMTS,
        OGCServer,
        Theme,
    )

    interface1 = Interface("interface1")
    dbsession.add(interface1)
    interface2 = Interface("interface2")
    dbsession.add(interface2)

    layers_wms = []
    ogc_server = OGCServer(name="ogc_server")
    dbsession.add(ogc_server)
    for i in range(10):
        layer_wms = LayerWMS(name=f"layer_wms_{i}")
        if i == 1:
            layer_wms.interfaces = [interface1]
        elif i > 1:
            layer_wms.interfaces = [interface1, interface2]
        layer_wms.ogc_server = ogc_server
        layers_wms.append(layer_wms)
        dbsession.add(layer_wms)

    layers_wmts = []
    for i in range(10):
        layer_wmts = LayerWMTS(name=f"layer_wmts_{i}")
        if i == 1:
            layer_wmts.interfaces = [interface1]
        elif i > 1:
            layer_wmts.interfaces = [interface1, interface2]
        layer_wmts.url = "http://localhost/wmts"
        layer_wmts.layer = layer_wmts.name
        layers_wmts.append(layer_wmts)
        dbsession.add(layer_wmts)

    groups = []
    for i in range(10):
        group = LayerGroup(name=f"layer_group_{i}")
        groups.append(group)
        dbsession.add(group)

        for j, items in enumerate((layers_wms, layers_wmts)):
            dbsession.add(
                LayergroupTreeitem(group=group, item=items[i], ordering=j))

    # a group in a group
    dbsession.add(
        LayergroupTreeitem(group=groups[9], item=groups[8], ordering=3))

    themes = []
    for i in range(5):
        theme = Theme(name=f"theme_{i}")
        themes.append(theme)
        dbsession.add(theme)
        if i == 1:
            theme.interfaces = [interface1]
        elif i > 1:
            theme.interfaces = [interface1, interface2]

        dbsession.add(
            LayergroupTreeitem(group=theme, item=groups[i], ordering=0))
        dbsession.add(
            LayergroupTreeitem(group=theme, item=groups[i + 5], ordering=1))

    themes[0].ordering = 1
    themes[3].ordering = 2
    themes[1].ordering = 3
    themes[2].ordering = 4
    themes[4].ordering = 5

    dbsession.flush()

    yield ({
        "themes": themes,
        "groups": groups,
        "layers_wms": layers_wms,
        "layers_wmts": layers_wmts,
        "ogc_servers": [ogc_server],
        "interfaces": [interface1, interface2],
    })
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Interface, LayerWMS, LayerWMTS, Dimension

        ogc_server, _ = create_default_ogcserver()
        main = Interface(name="main")

        layer_wms_1 = LayerWMS(name="__test_layer_wms_1", public=True)
        layer_wms_1.layer = "__test_layer_wms_1"
        layer_wms_1.interfaces = [main]
        layer_wms_1.ogc_server = ogc_server
        Dimension("A", "a", layer_wms_1)

        layer_wms_2 = LayerWMS(name="__test_layer_wms_2", public=True)
        layer_wms_2.layer = "__test_layer_wms_2"
        layer_wms_2.interfaces = [main]
        layer_wms_2.ogc_server = ogc_server
        Dimension("A", "b", layer_wms_2)

        layer_wms_3 = LayerWMS(name="__test_layer_wms_3", public=True)
        layer_wms_3.layer = "__test_layer_wms_3"
        layer_wms_3.interfaces = [main]
        layer_wms_3.ogc_server = ogc_server
        Dimension("A", None, layer_wms_3)

        layer_wms_4 = LayerWMS(name="__test_layer_wms_4", public=True)
        layer_wms_4.layer = "__test_layer_wms_4"
        layer_wms_4.interfaces = [main]
        layer_wms_4.ogc_server = ogc_server
        Dimension("A", "a", layer_wms_4)

        layer_wms_5 = LayerWMS(name="__test_layer_wms_5", public=True)
        layer_wms_5.layer = "__test_layer_wms_5"
        layer_wms_5.interfaces = [main]
        layer_wms_5.ogc_server = ogc_server
        Dimension("B", "b", layer_wms_5)

        layer_wms_6 = LayerWMS(name="__test_layer_wms_6", public=True)
        layer_wms_6.layer = "__test_layer_wms_6"
        layer_wms_6.interfaces = [main]
        layer_wms_6.ogc_server = ogc_server
        Dimension("FILTER", "countries:\"name\" IN ( 'Germany' , 'Italy' )", layer_wms_6)

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]
        Dimension("B", "b", layer_wmts)

        layer_wmts_2 = LayerWMTS(name="__test_layer_wmts_2", public=True)
        layer_wmts_2.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts_2.layer = "map"
        layer_wmts_2.interfaces = [main]
        Dimension("FILTER", "countries:\"name\" IN ( 'Germany' , 'Italy' )", layer_wmts_2)

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_wms_1, layer_wmts, layer_wmts_2]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_wms_1, layer_wms_2]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wms_1, layer_wms_3]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_wms_1, layer_wms_4]

        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_wms_1, layer_wms_5, layer_wms_6]

        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_wms_3]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1, layer_group_2, layer_group_3,
            layer_group_4, layer_group_5, layer_group_6,
        ]

        DBSession.add(theme)

        transaction.commit()
示例#11
0
def edit_url_test_data(dbsession, transact):
    del transact

    from c2cgeoportal_commons.models.main import (
        Functionality,
        Interface,
        LayerGroup,
        LayerWMS,
        LayerWMTS,
        OGCServer,
        RestrictionArea,
        Role,
        Theme,
    )

    restrictionareas = [
        RestrictionArea(name=f"restrictionarea_{i}") for i in range(0, 5)
    ]
    functionalities = {}
    for name in ("default_basemap", "default_theme"):
        functionalities[name] = []
        for v in range(0, 4):
            functionality = Functionality(name=name, value=f"value_{v}")
            dbsession.add(functionality)
            functionalities[name].append(functionality)

    interfaces = [
        Interface(name) for name in ["desktop", "mobile", "edit", "routing"]
    ]
    ogc_server = OGCServer(name="ogc_server")

    layers_wmts = []
    for i in range(0, 5):
        name = f"layer_wmts_{i}"
        layer_wmts = LayerWMTS(name=name)
        layer_wmts.layer = name
        layer_wmts.url = f"https://server{i}.net/wmts"
        layer_wmts.restrictionareas = [
            restrictionareas[i % 5], restrictionareas[(i + 2) % 5]
        ]
        if i % 10 != 1:
            layer_wmts.interfaces = [
                interfaces[i % 4], interfaces[(i + 2) % 4]
            ]
        layer_wmts.public = 1 == i % 2
        layer_wmts.image_type = "image/jpeg"
        dbsession.add(layer_wmts)
        layers_wmts.append(layer_wmts)

    layers_wms = []
    for i in range(0, 5):
        layer_wms = LayerWMS(name=f"layer_wms_{i}")
        layer_wms.layer = f"wms_layer_{i}"
        layer_wms.ogc_server = ogc_server
        layers_wms.append(layer_wms)
        dbsession.add(layer_wms)
        layers_wms.append(layer_wms)

    roles = []
    for i in range(0, 5):
        role = Role("secretary_" + str(i))
        role.functionalities = [
            functionalities["default_theme"][0],
        ]
        role.restrictionareas = [restrictionareas[0], restrictionareas[1]]
        dbsession.add(role)
        roles.append(role)

    dbsession.flush()

    group = LayerGroup(name="groups")
    dbsession.add(group)
    theme = Theme(name="theme")
    dbsession.add(theme)

    dbsession.flush()

    yield {
        "ogc_server": ogc_server,
        "layers_wmts": layers_wmts,
        "layers_wms": layers_wms,
        "restrictionareas": restrictionareas,
        "interfaces": interfaces,
        "themes": [theme],
        "group": group,
        "roles": roles,
    }
示例#12
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Interface, LayerGroup, LayerWMS, LayerWMTS, Theme

        DBSession.query(PointTest).delete()

        main = Interface(name="desktop")
        ogc_server = create_default_ogcserver()

        layer_wms_1 = LayerWMS(name="__test_layer_time_1", public=True)
        layer_wms_1.layer = "test_wmstime"
        layer_wms_1.time_mode = "value"
        layer_wms_1.interfaces = [main]
        layer_wms_1.ogc_server = ogc_server

        layer_wms_2 = LayerWMS(name="__test_layer_time_2", public=True)
        layer_wms_2.layer = "test_wmstime2"
        layer_wms_2.time_mode = "value"
        layer_wms_2.interfaces = [main]
        layer_wms_2.ogc_server = ogc_server

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_wms_group_1 = LayerWMS(name="__test_layer_time_group_1", public=True)
        layer_wms_group_1.layer = "test_wmstimegroup"
        layer_wms_group_1.time_mode = "range"
        layer_wms_group_1.time_widget = "datepicker"
        layer_wms_group_1.interfaces = [main]
        layer_wms_group_1.ogc_server = ogc_server

        layer_wms_group_2 = LayerWMS(name="__test_layer_time_group_2", public=True)
        layer_wms_group_2.layer = "test_wmstimegroup"
        layer_wms_group_2.time_mode = "value"
        layer_wms_group_2.interfaces = [main]
        layer_wms_group_2.ogc_server = ogc_server

        layer_wms_no_time = LayerWMS(name="__test_layer_without_time_info", public=True)
        layer_wms_no_time.layer = "test_wmsfeatures"
        layer_wms_no_time.time_mode = "value"
        layer_wms_no_time.interfaces = [main]
        layer_wms_no_time.ogc_server = ogc_server

        # Expect merge of times
        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_wms_1, layer_wms_2]

        # Expect time from layer.
        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_wms_1]

        # Expect merge of wms 1 and 2, layer_wms_group_1 excluded and in errors as its mode don't match.
        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wms_1, layer_wms_2, layer_wms_group_1]

        # Expect time from layers in wms layer group
        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_wms_group_1]

        # Expect merge of wms 1 and 2 and group.
        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_wms_1, layer_wms_2, layer_wms_group_2]

        # Expect individual layers
        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_wms_1, layer_wms_2, layer_wmts]

        # Expect layer_wms_no_time excluded and in errors as it has no time info
        layer_group_7 = LayerGroup(name="__test_layer_group_7")
        layer_group_7.children = [layer_wms_1, layer_wms_no_time]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1,
            layer_group_2,
            layer_group_3,
            layer_group_4,
            layer_group_5,
            layer_group_6,
            layer_group_7,
        ]

        DBSession.add_all([theme])

        transaction.commit()
示例#13
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Functionality, Interface, \
            LayerV1, OGCServer, LayerWMS, LayerWMTS, \
            Metadata, Dimension, OGCSERVER_AUTH_NOAUTH

        main = Interface(name="desktop")
        mobile = Interface(name="mobile")
        min_levels = Interface(name="min_levels")

        layer_v1 = LayerV1(name="__test_layer_v1", public=True)
        layer_v1.interfaces = [main]
        layer_v1.metadatas = [Metadata("test", "v1")]

        ogc_server_internal, _ = create_default_ogcserver()
        ogc_server_external = OGCServer(
            name="__test_ogc_server_chtopo", url="http://wms.geo.admin.ch/",
            image_type="image/jpeg", auth=OGCSERVER_AUTH_NOAUTH
        )
        ogc_server_external.wfs_support = False

        layer_internal_wms = LayerWMS(name="__test_layer_internal_wms", public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main, min_levels]
        layer_internal_wms.metadatas = [Metadata("test", "internal_wms")]
        layer_internal_wms.ogc_server = ogc_server_internal

        layer_external_wms = LayerWMS(name="__test_layer_external_wms", layer="ch.swisstopo.dreiecksvermaschung", public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.metadatas = [Metadata("test", "external_wms")]
        layer_external_wms.ogc_server = ogc_server_external

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main, mobile]
        layer_wmts.metadatas = [Metadata("test", "wmts")]
        layer_wmts.dimensions = [Dimension("year", "2015")]

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_v1, layer_internal_wms, layer_external_wms, layer_wmts]
        layer_group_1.metadatas = [Metadata("test", "group_1")]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_wmts, layer_internal_wms, layer_external_wms]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wmts, layer_internal_wms, layer_external_wms]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_group_2]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main, mobile]
        theme.metadatas = [Metadata("test", "theme")]
        theme.children = [
            layer_group_1, layer_group_2
        ]
        theme_layer = Theme(name="__test_theme_layer")
        theme_layer.interfaces = [min_levels]
        theme_layer.children = [
            layer_internal_wms
        ]

        functionality1 = Functionality(name="test_name", value="test_value_1")
        functionality2 = Functionality(name="test_name", value="test_value_2")
        theme.functionalities = [functionality1, functionality2]

        DBSession.add_all([theme, theme_layer])

        transaction.commit()
示例#14
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Theme, LayerGroup, Interface, OGCServer, LayerWMS, LayerWMTS

        main = Interface(name="main")

        ogc_server_internal, _ = create_default_ogcserver()
        ogc_server_external = OGCServer(name="__test_ogc_server_external", url="http://wms.geo.admin.ch/", image_type="image/jpeg")

        layer_internal_wms = LayerWMS(name="__test_layer_internal_wms", public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main]
        layer_internal_wms.ogc_server = ogc_server_internal

        layer_external_wms = LayerWMS(name="__test_layer_external_wms", layer="ch.swisstopo.dreiecksvermaschung", public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.ogc_server = ogc_server_external

        layer_wmts = LayerWMTS(name="__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_group_1 = LayerGroup(name="__test_layer_group_1")
        layer_group_1.children = [layer_internal_wms]

        layer_group_2 = LayerGroup(name="__test_layer_group_2")
        layer_group_2.children = [layer_external_wms]

        layer_group_3 = LayerGroup(name="__test_layer_group_3")
        layer_group_3.children = [layer_wmts]

        layer_group_4 = LayerGroup(name="__test_layer_group_4")
        layer_group_4.children = [layer_group_1, layer_group_2]

        layer_group_5 = LayerGroup(name="__test_layer_group_5")
        layer_group_5.children = [layer_group_1, layer_group_3]

        layer_group_6 = LayerGroup(name="__test_layer_group_6")
        layer_group_6.children = [layer_internal_wms]

        layer_group_7 = LayerGroup(name="__test_layer_group_7")
        layer_group_7.children = [layer_group_1, layer_group_6]

        layer_group_8 = LayerGroup(name="__test_layer_group_8")
        layer_group_8.children = [layer_group_2, layer_group_6]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group_1, layer_group_2, layer_group_3,
            layer_group_4, layer_group_5,
            layer_group_7, layer_group_8,
        ]

        DBSession.add(theme)

        transaction.commit()