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()
 def layer_builder(i):
     name = f"layer_wmts_{i}"
     layer = LayerWMTS(name=name)
     layer.layer = name
     layer.url = f"https:///wms.geo.admin.ch_{i}.org?service=wms&request=GetCapabilities"
     layer.public = 1 == i % 2
     layer.geo_table = f"geotable_{i}"
     layer.image_type = "image/jpeg"
     layer.style = "décontrasté"
     return layer
Beispiel #3
0
 def layer_builder(i):
     name = 'layer_wmts_{}'.format(i)
     layer = LayerWMTS(name=name)
     layer.layer = name
     layer.url = 'https:///wms.geo.admin.ch_{}.org?service=wms&request=GetCapabilities'.format(i)
     layer.public = 1 == i % 2
     layer.geo_table = 'geotable_{}'.format(i)
     layer.image_type = 'image/jpeg'
     layer.style = 'décontrasté'
     return layer
    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()
Beispiel #5
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 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
    }
Beispiel #7
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,
    }