def setup_method(self, _):
        import transaction

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Functionality, Role
        from c2cgeoportal_commons.models.static import User

        create_default_ogcserver()
        role1 = Role(name="__test_role1")
        user1 = User(username="******", password="******", settings_role=role1, roles=[role1])
        role2 = Role(name="__test_role2")
        user2 = User(username="******", password="******", settings_role=role2, roles=[role2])
        role3 = Role(name="__test_role3")
        role4 = Role(name="__test_role4")
        user3 = User(
            username="******", password="******", roles=[role3, role4], settings_role=role3
        )

        functionality1 = Functionality("__test_s", "db")
        functionality2 = Functionality("__test_a", "db1")
        functionality3 = Functionality("__test_a", "db2")
        functionality4 = Functionality("__test_b", "db")
        role2.functionalities = [functionality1, functionality2, functionality3]
        role3.functionalities = [functionality1, functionality2]
        role4.functionalities = [functionality2, functionality3, functionality4]

        DBSession.add_all([user1, user2, user3, role1, role2])
        transaction.commit()
    def setup_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, Functionality
        from c2cgeoportal_commons.models.static import User

        create_default_ogcserver()
        role1 = Role(name="__test_role1")
        user1 = User(username="******",
                     password="******",
                     role=role1)
        role2 = Role(name="__test_role2")
        user2 = User(username="******",
                     password="******",
                     role=role2)

        functionality1 = Functionality("__test_s", "db")
        functionality2 = Functionality("__test_a", "db1")
        functionality3 = Functionality("__test_a", "db2")
        role2.functionalities = [
            functionality1, functionality2, functionality3
        ]

        DBSession.add_all([user1, user2, role1, role2])
        transaction.commit()
    def setup_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, Functionality
        from c2cgeoportal_commons.models.static import User

        create_default_ogcserver()
        role1 = Role(name="__test_role1")
        user1 = User(
            username="******",
            password="******",
            role=role1
        )
        role2 = Role(name="__test_role2")
        user2 = User(
            username="******",
            password="******",
            role=role2
        )

        functionality1 = Functionality("__test_s", "db")
        functionality2 = Functionality("__test_a", "db1")
        functionality3 = Functionality("__test_a", "db2")
        role2.functionalities = [functionality1, functionality2, functionality3]

        DBSession.add_all([user1, user2, role1, role2])
        transaction.commit()
Esempio n. 4
0
def roles_test_data(dbsession, transact):
    del transact

    from c2cgeoportal_commons.models.main import Role, Functionality, RestrictionArea
    from c2cgeoportal_commons.models.static import User

    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)

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

    roles = []
    for i in range(0, 23):
        role = Role('secretary_' + str(i))
        role.functionalities = [
            functionalities['default_basemap'][0],
            functionalities['location'][0],
            functionalities['location'][1]]
        role.restrictionareas = [
            restrictionareas[0],
            restrictionareas[1]]
        role.extent = from_shape(box(485869.5728, 76443.1884, 837076.5648, 299941.7864),
                                 srid=21781)
        dbsession.add(role)
        roles.append(role)

    # Users roles must not be broken with role name changes
    users = []
    for i in range(0, 23):
        user = User("babar_" + str(i),
                    email='mail' + str(i),
                    settings_role=roles[i],
                    roles=[roles[i]])
        user.password = '******'
        user.is_password_changed = i % 2 == 1
        users.append(user)
        dbsession.add(user)

    dbsession.flush()

    yield {
        'functionalities': functionalities,
        'restrictionareas': restrictionareas,
        'users': users,
        'roles': roles
    }
Esempio n. 5
0
def roles_test_data(dbsession, transact):
    del transact

    from c2cgeoportal_commons.models.main import Functionality, RestrictionArea, Role
    from c2cgeoportal_commons.models.static import User

    # Note that "default_basemap" is not relevant for roles
    functionalities = {}
    for name in ("default_basemap", "default_theme", "print_template"):
        functionalities[name] = []
        for v in range(0, 4):
            functionality = Functionality(name=name, value=f"value_{v}")
            dbsession.add(functionality)
            functionalities[name].append(functionality)

    restrictionareas = []
    for i in range(0, 5):
        restrictionarea = RestrictionArea(name=f"restrictionarea_{i}")
        dbsession.add(restrictionarea)
        restrictionareas.append(restrictionarea)

    roles = []
    for i in range(0, 23):
        role = Role("secretary_" + str(i))
        role.functionalities = [
            functionalities["default_theme"][0],
            functionalities["print_template"][0],
            functionalities["print_template"][1],
        ]
        role.restrictionareas = [restrictionareas[0], restrictionareas[1]]
        role.extent = from_shape(box(485869.5728, 76443.1884, 837076.5648,
                                     299941.7864),
                                 srid=21781)
        dbsession.add(role)
        roles.append(role)

    # Users roles must not be broken with role name changes
    users = []
    for i in range(0, 23):
        user = User("babar_" + str(i),
                    email="mail" + str(i),
                    settings_role=roles[i],
                    roles=[roles[i]])
        user.password = "******"
        user.is_password_changed = i % 2 == 1
        users.append(user)
        dbsession.add(user)

    dbsession.flush()

    yield {
        "functionalities": functionalities,
        "restrictionareas": restrictionareas,
        "users": users,
        "roles": roles,
    }
Esempio n. 6
0
def roles_test_data(dbsession):
    from c2cgeoportal_commons.models.main import Role, Functionality, RestrictionArea
    dbsession.begin_nested()

    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)

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

    roles = []
    for i in range(0, 23):
        role = Role('secretary_' + str(i))
        role.functionalities = [
            functionalities['default_basemap'][0],
            functionalities['location'][0],
            functionalities['location'][1]]
        role.restrictionareas = [
            restrictionareas[0],
            restrictionareas[1]]
        role.extent = from_shape(box(485869.5728, 76443.1884, 837076.5648, 299941.7864),
                                 srid=21781)
        dbsession.add(role)
        roles.append(role)

    dbsession.flush()

    yield {
        'functionalities': functionalities,
        'restrictionareas': restrictionareas,
        'roles': roles
    }

    dbsession.rollback()
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
    }
Esempio n. 8
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,
    }