Пример #1
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.models import DBSession, LayerV1, Theme, Interface, LayerGroup

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

        layer = LayerV1(name="__test_layer")
        layer.interfaces = [main, mobile]

        mobile_only_layer = LayerV1(name="__test_mobile_only_layer")
        mobile_only_layer.interfaces = [mobile]

        desktop_only_layer = LayerV1(name="__test_desktop_only_layer")
        desktop_only_layer.interfaces = [main]

        group = LayerGroup(name="__test_layer_group")
        group.children = [layer, mobile_only_layer, desktop_only_layer]
        theme = Theme(name="__test_theme")
        theme.children = [group]
        theme.interfaces = [main, mobile]

        mobile_only_group = LayerGroup(name="__test_mobile_only_layer_group")
        mobile_only_group.children = [layer]
        mobile_only_theme = Theme(name="__test_mobile_only_theme")
        mobile_only_theme.children = [mobile_only_group]
        mobile_only_theme.interfaces = [mobile]

        desktop_only_group = LayerGroup(name="__test_desktop_only_layer_group")
        desktop_only_group.children = [layer]
        desktop_only_theme = Theme(name="__test_desktop_only_theme")
        desktop_only_theme.children = [desktop_only_group]
        desktop_only_theme.interfaces = [main]

        # the following theme should not appear in the list of themes on desktop
        # nor on mobile
        # It should be accessible by explicitely loading it in mobile though
        mobile_private_group = LayerGroup(
            name="__test_mobile_private_layer_group")
        mobile_private_group.children = [layer]
        mobile_private_theme = Theme(name="__test_mobile_private_theme")
        mobile_private_theme.children = [mobile_private_group]

        DBSession.add_all([
            layer, mobile_only_layer, desktop_only_layer, theme,
            mobile_only_theme, desktop_only_theme, mobile_private_theme
        ])
        transaction.commit()
    def setUp(self):  # noqa
        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Interface, DBSession

        create_default_ogcserver()

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer1 = LayerV1(u"testpoint_group", public=False)
        layer1.interfaces = [main]

        layer2 = LayerV1(u"testpoint_protected_2", public=False)
        layer2.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"", [layer1, layer2], [role1], area)

        DBSession.add_all([user1, role1, layer1, layer2, restricted_area1])
        DBSession.flush()

        transaction.commit()
Пример #3
0
    def setUp(self):  # noqa
        import sqlahelper
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface, TreeItem
        from c2cgeoportal.lib.dbreflection import init

        for treeitem in DBSession.query(TreeItem).all():
            DBSession.delete(treeitem)

        self.metadata = None
        self.layer_ids = []

        self.role = Role(name=u"__test_role")
        self.user = User(username=u"__test_user",
                         password=u"__test_user",
                         role=self.role)
        self.main = Interface(name=u"main")

        DBSession.add(self.user)
        DBSession.add(self.role)
        DBSession.add(self.main)
        transaction.commit()

        engine = sqlahelper.get_engine()
        init(engine)
Пример #4
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal.models import DBSession, \
            Theme, LayerGroup, Interface, LayerWMS

        main = Interface(name=u"desktop")

        ogc_server, _ = create_default_ogcserver()

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

        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [layer_wms]

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

        DBSession.add(theme)
        transaction.commit()
    def setup_method(self, _):
        from c2cgeoportal.models import User, Role, LayerWMS, RestrictionArea, \
            Interface, DBSession

        ogc_server_internal, _ = create_default_ogcserver()

        user1 = User(username="******", password="******")
        role1 = Role(name="__test_role1", description="__test_role1")
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        main = Interface(name="main")

        layer1 = LayerWMS("testpoint_group_name", public=False)
        layer1.layer = "testpoint_group"
        layer1.ogc_server = ogc_server_internal
        layer1.interfaces = [main]

        layer2 = LayerWMS("testpoint_protected_2_name", public=False)
        layer2.layer = "testpoint_protected_2"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer1, layer2],
                                           [role1], area)

        DBSession.add_all([user1, role1, layer1, layer2, restricted_area1])
        DBSession.flush()

        transaction.commit()
Пример #6
0
    def setUp(self):  # noqa
        import transaction
        from sqlalchemy import func
        from geoalchemy2 import WKTElement
        from c2cgeoportal.models import FullTextSearch, User, Role, Interface
        from c2cgeoportal.models import DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name

        entry1 = FullTextSearch()
        entry1.label = "label1"
        entry1.layer_name = "layer1"
        entry1.ts = func.to_tsvector("french", "soleil travail")
        entry1.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = "label2"
        entry2.layer_name = "layer2"
        entry2.ts = func.to_tsvector("french", "pluie semaine")
        entry2.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = "label3"
        entry3.layer_name = "layer3"
        entry3.ts = func.to_tsvector("french", "vent neige")
        entry3.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = "label4"
        entry4.layer_name = "layer1"
        entry4.ts = func.to_tsvector("french", "soleil travail")
        entry4.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = "label5"
        entry5.ts = func.to_tsvector("french", "params")
        entry5.public = True
        entry5.params = {"floor": 5}
        entry5.actions = [{"action": "add_layer", "data": "layer1"}]

        entry6 = FullTextSearch()
        entry6.label = "label6"
        entry6.ts = func.to_tsvector("french", "params")
        entry6.interface = Interface("main")
        entry6.public = True

        DBSession.add_all([user1, user2, role1, role2, entry1, entry2, entry3, entry4, entry5, entry6])
        transaction.commit()
Пример #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.models import DBSession, \
            Theme, LayerGroup, Interface, LayerWMS, Metadata

        main = Interface(name="desktop")

        ogc_server, _ = create_default_ogcserver()

        layer_noscale = LayerWMS(name="__test_layer_noscale", public=True)
        layer_noscale.layer = "test_noscale"
        layer_noscale.interfaces = [main]
        layer_noscale.ogc_server = ogc_server

        layer_minscale = LayerWMS(name="__test_layer_minscale", public=True)
        layer_minscale.layer = "test_minscale"
        layer_minscale.interfaces = [main]
        layer_minscale.ogc_server = ogc_server

        layer_maxscale = LayerWMS(name="__test_layer_maxscale", public=True)
        layer_maxscale.layer = "test_maxscale"
        layer_maxscale.interfaces = [main]
        layer_maxscale.ogc_server = ogc_server

        layer_boothscale = LayerWMS(name="__test_layer_boothscale", public=True)
        layer_boothscale.layer = "test_boothscale"
        layer_boothscale.interfaces = [main]
        layer_boothscale.ogc_server = ogc_server

        layer_metadatascale = LayerWMS(name="__test_layer_metadatascale", public=True)
        layer_metadatascale.layer = "test_boothscale"
        layer_metadatascale.interfaces = [main]
        layer_metadatascale.ogc_server = ogc_server
        layer_metadatascale.metadatas = [
            Metadata("minResolution", "100"),
            Metadata("maxResolution", "1000"),
        ]

        layer_group = LayerGroup(name="__test_layer_group")
        layer_group.children = [layer_noscale, layer_minscale, layer_maxscale, layer_boothscale, layer_metadatascale]

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

        DBSession.add_all([theme])

        transaction.commit()
Пример #8
0
    def setUp(self):  # noqa
        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Interface, DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer1 = LayerV1(u"layer_1", public=False)
        layer1.interfaces = [main]
        layer2 = LayerV1(u"layer_2", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"layer_3", public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1",
                                           u"", [layer1, layer2], [role1],
                                           area,
                                           readwrite=True)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"",
                                           [layer1, layer2, layer3], [role2],
                                           area)

        DBSession.add_all(
            [user1, user2, role1, role2, restricted_area1, restricted_area2])
        DBSession.flush()

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

        cleanup_db()

        self._tables = []

        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface, TreeItem, Theme, \
            LayerGroup, OGCSERVER_AUTH_NOAUTH

        for treeitem in DBSession.query(TreeItem).all():
            DBSession.delete(treeitem)

        self.role = Role(name="__test_role")
        self.user = User(
            username="******",
            password="******",
            role=self.role
        )
        self.main = Interface(name="main")

        self.ogc_server, external_ogc_server = create_default_ogcserver()
        self.ogc_server.auth = OGCSERVER_AUTH_NOAUTH
        external_ogc_server.auth = OGCSERVER_AUTH_NOAUTH

        self.metadata = None
        self.layer_ids = []

        self.layer_group_1 = LayerGroup(name="__test_layer_group_1")

        theme = Theme(name="__test_theme")
        theme.interfaces = [self.main]
        theme.children = [self.layer_group_1]

        DBSession.add_all([self.main, self.user, self.role, theme, self.layer_group_1])

        transaction.commit()
Пример #10
0
    def setup_method(self, _):
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface

        cleanup_db()

        self.metadata = None
        self.layer_ids = []

        DBSession.query(User).delete()
        DBSession.query(User).filter(User.username == "__test_user").delete()

        self.role = Role(name="__test_role")
        self.user = User(username="******",
                         password="******",
                         role=self.role)
        self.main = Interface(name="main")

        DBSession.add(self.user)
        DBSession.add(self.role)
        DBSession.add(self.main)
        transaction.commit()
Пример #11
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal.models import DBSession, LayerV1, \
            Theme, LayerGroup, Interface

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

        layer = LayerV1(name=u"__test_layer", public=True)
        layer.interfaces = [main]

        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [layer, layer_group]

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

        DBSession.add_all([layer, layer_group, theme])
        transaction.commit()
    def setup_method(self, _):
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerWMS, RestrictionArea, \
            Interface, DBSession, OGCServer, \
            OGCSERVER_TYPE_MAPSERVER, OGCSERVER_AUTH_STANDARD

        cleanup_db()
        create_default_ogcserver()

        ogcserver_jpeg = OGCServer(name="__test_ogc_server_jpeg")
        ogcserver_jpeg.url = mapserv_url
        ogcserver_jpeg.image_type = "image/jpeg"
        ogcserver_jpeg.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_jpeg.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_png = OGCServer(name="__test_ogc_server_png")
        ogcserver_png.url = mapserv_url
        ogcserver_png.image_type = "image/png"
        ogcserver_png.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_png.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_wfs1 = OGCServer(name="__test_ogc_server_wfs1")
        ogcserver_wfs1.url = mapserv_url
        ogcserver_wfs1.url_wfs = "config://srv"
        ogcserver_wfs1.image_type = "image/png"
        ogcserver_wfs1.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_wfs1.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_wfs2 = OGCServer(name="__test_ogc_server_wfs2")
        ogcserver_wfs2.url = "config://srv"
        ogcserver_wfs2.url_wfs = mapserv_url
        ogcserver_wfs2.image_type = "image/png"
        ogcserver_wfs2.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_wfs2.auth = OGCSERVER_AUTH_STANDARD

        role = Role(name="__test_role", description="__test_role")
        user = User(username="******", password="******")
        user.role_name = "__test_role"

        main = Interface(name="main")

        layer1 = LayerWMS("__test_layer1", public=False)
        layer1.layer = "__test_private_layer1"
        layer1.ogc_server = ogcserver_jpeg
        layer1.interfaces = [main]

        layer2 = LayerWMS("__test_layer2", public=False)
        layer2.layer = "__test_private_layer2"
        layer2.ogc_server = ogcserver_png
        layer2.interfaces = [main]

        layer3 = LayerWMS("__test_layer3", public=False)
        layer3.layer = "__test_private_layer3"
        layer3.ogc_server = ogcserver_wfs1
        layer3.interfaces = [main]

        layer4 = LayerWMS("__test_layer4", public=False)
        layer4.layer = "__test_private_layer4"
        layer4.ogc_server = ogcserver_wfs2
        layer4.interfaces = [main]

        restricted_area = RestrictionArea("__test_ra", "",
                                          [layer1, layer2, layer3, layer4],
                                          [role])

        DBSession.add_all([user, restricted_area])
        transaction.commit()
Пример #13
0
    def setUp(self):  # noqa
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Functionality, Interface, DBSession, management, OGCServer, \
            OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER

        if management:
            TestPoint.__table__.c.the_geom.type.management = True

        create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

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

        geom = WKTElement("MULTIPOINT((-90 -45))", srid=21781)
        p1 = TestPoint(the_geom=geom,
                       name=u"foo",
                       city=u"Lausanne",
                       country=u"Swiss")
        geom = WKTElement("MULTIPOINT((-90 45))", srid=21781)
        p2 = TestPoint(the_geom=geom,
                       name=u"bar",
                       city=u"Chambéry",
                       country=u"France")
        geom = WKTElement("MULTIPOINT((90 45))", srid=21781)
        p3 = TestPoint(the_geom=geom,
                       name=u"éàè",
                       city="Paris",
                       country=u"France")
        geom = WKTElement("MULTIPOINT((90 -45))", srid=21781)
        p4 = TestPoint(the_geom=geom,
                       name=u"123",
                       city="Londre",
                       country=u"UK")

        pt1 = Functionality(name=u"print_template",
                            value=u"1 Wohlen A4 portrait")
        pt2 = Functionality(name=u"print_template",
                            value=u"2 Wohlen A3 landscape")
        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1",
                     description=u"__test_role1",
                     functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2",
                     description=u"__test_role2",
                     functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        user3 = User(username=u"__test_user3", password=u"__test_user3")
        role3 = Role(name=u"__test_role3",
                     description=u"__test_role3",
                     functionalities=[pt1, pt2])
        user3.role_name = role3.name
        user3.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer2 = LayerV1(u"testpoint_protected", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"testpoint_protected_query_with_collect",
                         public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"",
                                           [layer2, layer3], [role1], area)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"",
                                           [layer2, layer3], [role2, role3],
                                           area)

        area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea(u"__test_ra3",
                                           u"", [layer3], [role3],
                                           area,
                                           readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3,
            ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id

        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.models import DBSession, \
            Theme, LayerGroup, Interface, LayerWMS, Metadata

        desktop = Interface(name="desktop")

        ogc_server_internal, _ = create_default_ogcserver()

        layer_wms = LayerWMS(name="__test_layer_internal_wms", public=True)
        layer_wms.layer = "__test_layer_internal_wms"
        layer_wms.ogc_server = ogc_server_internal
        layer_wms.interfaces = [desktop]
        layer_wms.metadatas = [
            Metadata("string", "string"),
            Metadata("list", "1, 2, a"),
            Metadata("boolean", "y"),
            Metadata("boolean2", "no"),
            Metadata("boolean3", "Hello"),
            Metadata("integer", "1"),
            Metadata("float", "5.5"),
            Metadata("json", '{"test": 123}'),
            Metadata("json_wrong", '{"test": 123'),
            Metadata("date", "Sep 25 2003"),
            Metadata("time", "10:36:28"),
            Metadata("datetime", "Sep 25 10:36:28 BRST 2003"),
            Metadata("date2", "Sep 25 10:36:28 BRST 2003"),
            Metadata("time2", "Sep 25 10:36:28 BRST 2003"),
            Metadata("datetime2", "Hello"),
            Metadata("url1", "http://example.com/hi?a=b#c"),
            Metadata("url2", "static:///path/icon.png"),
            Metadata("url3", "static://static/path/icon.png"),
            Metadata("url4", "static://cgxp/path/icon.png"),
            Metadata("url5", "static://project:static/path/icon.png"),
            Metadata("url6", "static://project:cgxp/path/icon.png"),
            Metadata("url7", "config://server"),
            Metadata("url8", "config://server/index.html"),
            Metadata("url9", "/dummy/static/icon.png"),
            Metadata("url10", "dummy/static/icon.png"),
            Metadata("url11", "https:///static/icon.png"),
            Metadata("url12", "static://test"),
            Metadata("url13", "static://test/"),
            Metadata("url14", "config:///static/icon.png"),
            Metadata("url15", "config://unknown_server"),
            Metadata("url16", "https://"),
            Metadata("url17", "https:///"),
            Metadata("url18", "https:///static"),
            Metadata("url19", ""),
            Metadata("url20", "/"),
            Metadata("unknown", "Hello"),
        ]

        layer_group = LayerGroup(name="__test_layer_group")
        layer_group.children = [layer_wms]

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

        DBSession.add(theme)

        transaction.commit()
Пример #15
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.models import User, Role, LayerWMS, RestrictionArea, \
            Functionality, Interface, DBSession, OGCServer, \
            OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER

        cleanup_db()

        ogc_server_internal, _ = create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv_url
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

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

        geom = WKTElement("POINT(599910 199955)", srid=21781)
        p1 = PointTest(geom=geom, name="foo", city="Lausanne", country="Swiss")
        geom = WKTElement("POINT(599910 200045)", srid=21781)
        p2 = PointTest(geom=geom, name="bar", city="Chambéry", country="France")
        geom = WKTElement("POINT(600090 200045)", srid=21781)
        p3 = PointTest(geom=geom, name="éàè", city="Paris", country="France")
        geom = WKTElement("POINT(600090 199955)", srid=21781)
        p4 = PointTest(geom=geom, name="123", city="Londre", country="UK")

        pt1 = Functionality(name="print_template", value="1 Wohlen A4 portrait")
        pt2 = Functionality(name="print_template", value="2 Wohlen A3 landscape")
        user1 = User(username="******", password="******")
        role1 = Role(name="__test_role1", description="__test_role1", functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        user2 = User(username="******", password="******")
        role2 = Role(name="__test_role2", description="__test_role2", functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = "Tarenpion"

        user3 = User(username="******", password="******")
        role3 = Role(name="__test_role3", description="__test_role3", functionalities=[pt1, pt2])
        user3.role_name = role3.name

        main = Interface(name="main")

        layer2 = LayerWMS("testpoint_protected", public=False)
        layer2.layer = "testpoint_protected"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        layer3 = LayerWMS("testpoint_protected_query_with_collect", public=False)
        layer3.layer = "testpoint_protected_query_with_collect"
        layer3.ogc_server = ogc_server_internal
        layer3.interfaces = [main]

        area = "POLYGON((599900 200030, 599900 200050, 600100 200050, 600100 200030, 599900 200030))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer2, layer3], [role1], area)

        area = "POLYGON((599900 200000, 599900 200020, 600100 200020, 600100 200000, 599900 200000))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea("__test_ra2", "", [layer2, layer3], [role2, role3], area)

        area = "POLYGON((599905 200043, 599905 200047, 600095 200047, 600095 200043, 599905 200043))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea("__test_ra3", "", [layer3], [role3], area, readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3, ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id
        self.ogc_server_id = ogc_server_internal.id
        self.role1_id = role1.id
        self.role2_id = role2.id
        self.role3_id = role3.id

        transaction.commit()
Пример #16
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.models import DBSession, \
            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()
Пример #17
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.models import DBSession, \
            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()
Пример #18
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        functionality.FUNCTIONALITIES_TYPES = None

        from c2cgeoportal.models import DBSession, User, Role, \
            RestrictionArea, Theme, LayerGroup, Interface, LayerWMS

        ogcserver, ogcserver_external = create_default_ogcserver()

        role1 = Role(name=u"__test_role1")
        role1.id = 999
        user1 = User(username=u"__test_user1",
                     password=u"__test_user1",
                     role=role1)
        user1.email = "*****@*****.**"

        role2 = Role(name=u"__test_role2",
                     extent=WKTElement("POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))",
                                       srid=21781))
        user2 = User(username=u"__test_user2",
                     password=u"__test_user2",
                     role=role2)

        main = Interface(name=u"main")

        private_layer = LayerWMS(name=u"__test_private_layer", public=False)
        private_layer.layer = "__test_private_layer"
        private_layer.geo_table = "a_schema.a_geo_table"
        private_layer.interfaces = [main]
        private_layer.ogc_server = ogcserver

        group = LayerGroup(name=u"__test_layer_group")
        group.children = [private_layer]

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

        DBSession.add(
            RestrictionArea(
                name=u"__test_ra1",
                description=u"",
                layers=[private_layer],
                roles=[role1],
            ))
        DBSession.add(
            RestrictionArea(
                name=u"__test_ra2",
                description=u"",
                layers=[private_layer],
                roles=[role2],
                readwrite=True,
            ))

        DBSession.add_all([
            user1,
            user2,
            role1,
            role2,
            theme,
            group,
            private_layer,
        ])

        transaction.commit()
Пример #19
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.models import DBSession, \
            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()
Пример #20
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.models import DBSession, \
            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()
Пример #21
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None
        self._tables = []

        functionality.FUNCTIONALITIES_TYPES = None

        from c2cgeoportal.models import DBSession, User, Role, \
            RestrictionArea, TreeItem, Theme, LayerGroup, Interface, LayerWMS

        from sqlalchemy import Column, Table, types
        from sqlalchemy.ext.declarative import declarative_base
        from geoalchemy2 import Geometry

        for o in DBSession.query(RestrictionArea).all():
            DBSession.delete(o)
        for o in DBSession.query(Role).all():
            DBSession.delete(o)
        for o in DBSession.query(User).all():
            DBSession.delete(o)
        for o in DBSession.query(TreeItem).all():
            DBSession.delete(o)
        ogcserver, ogcserver_external = create_default_ogcserver()

        role1 = Role(name="__test_role1")
        role1.id = 999
        user1 = User(username="******", password="******", role=role1)
        user1.email = "*****@*****.**"

        role2 = Role(name="__test_role2", extent=WKTElement(
            "POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))", srid=21781
        ))
        user2 = User(username="******", password="******", role=role2)

        main = Interface(name="main")

        engine = DBSession.c2c_rw_bind
        engine.connect()
        a_geo_table = Table(
            "a_geo_table", declarative_base(bind=engine).metadata,
            Column("id", types.Integer, primary_key=True),
            Column("geom", Geometry("POINT", srid=21781)),
            schema="geodata"
        )

        self._tables = [a_geo_table]
        a_geo_table.drop(checkfirst=True)
        a_geo_table.create()

        private_layer = LayerWMS(name="__test_private_layer", public=False)
        private_layer.layer = "__test_private_layer"
        private_layer.geo_table = "geodata.a_geo_table"
        private_layer.interfaces = [main]
        private_layer.ogc_server = ogcserver

        group = LayerGroup(name="__test_layer_group")
        group.children = [private_layer]

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

        DBSession.add(RestrictionArea(
            name="__test_ra1", description="", layers=[private_layer],
            roles=[role1],
        ))
        DBSession.add(RestrictionArea(
            name="__test_ra2", description="", layers=[private_layer],
            roles=[role2], readwrite=True,
        ))

        DBSession.add_all([
            user1, user2, role1, role2, theme, group, private_layer,
        ])

        transaction.commit()