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()
Example #2
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, OGCServer, LayerWMS, LayerWMTS

        main = Interface(name=u"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=u"__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=u"__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=u"__test_layer_wmts", public=True)
        layer_wmts.interfaces = [main]

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

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

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

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

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

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

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

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

        theme = Theme(name=u"__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 main():
    parser = argparse.ArgumentParser(description="Create and populate the database tables.")
    parser.add_argument("-i", "--iniconfig", default="production.ini", help="project .ini config file")
    parser.add_argument("-n", "--app-name", default="app", help='The application name (optional, default is "app")')

    options = parser.parse_args()

    # read the configuration
    get_app(options.iniconfig, options.app_name)

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

    session = DBSession()

    interfaces = session.query(Interface).all()
    ogc_server = session.query(OGCServer).filter(OGCServer.name == u"source for image/png").one()

    layer_borders = LayerWMS(u"Borders", u"borders")
    layer_borders.interfaces = interfaces
    layer_borders.ogc_server = ogc_server
    layer_density = LayerWMS(u"Density", u"density")
    layer_density.interfaces = interfaces
    layer_density.ogc_server = ogc_server

    group = LayerGroup(u"Demo")
    group.children = [layer_borders, layer_density]

    theme = Theme(u"Demo")
    theme.children = [group]
    theme.interfaces = interfaces

    transaction.commit()
Example #4
0
    def setUp(self):
        from c2cgeoportal.models import DBSession, Layer, Theme, LayerGroup

        layer = Layer(name=u"__test_layer", public=True)
        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]

        DBSession.add_all([layer, layer_group, theme])
        transaction.commit()
    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, ServerOGC

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

        main = Interface(name=u"main")

        layer_wms_1 = LayerWMS(name=u"__test_layer_time_1", public=True)
        layer_wms_1.layer = "test_wmstime"
        layer_wms_1.time_mode = "single"
        layer_wms_1.interfaces = [main]
        layer_wms_1.server_ogc = ServerOGC(name="__test_server_ogc", type="mapserver", image_type="image/jpeg")

        layer_wms_2 = LayerWMS(name=u"__test_layer_time_2", public=True)
        layer_wms_2.layer = "test_wmstime2"
        layer_wms_2.time_mode = "single"
        layer_wms_2.interfaces = [main]
        layer_wms_2.server_ogc = ServerOGC(name="__test_server_ogc", type="mapserver", image_type="image/jpeg")

        layer_wms_group = LayerWMS(name=u"__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.server_ogc = ServerOGC(name="__test_server_ogc", type="mapserver", image_type="image/jpeg")

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

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

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

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

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

        DBSession.add_all([theme])

        transaction.commit()
    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()
Example #7
0
    def setUp(self):
        self.config = testing.setUp()

        from c2cgeoportal.models import DBSession, Layer, \
                Theme, LayerGroup

        layer = Layer(name=u'__test_layer', public=True)
        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]

        DBSession.add_all([layer, layer_group, theme])
        transaction.commit()
Example #8
0
    def setUp(self):
        from c2cgeoportal.models import DBSession, User, Role, Layer, \
            RestrictionArea, Theme, LayerGroup

        role1 = Role(name=u'__test_role1')
        user1 = User(username=u'__test_user1', password=u'__test_user1', role=role1)

        role2 = Role(name=u'__test_role2', extent=WKTSpatialElement(
            "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)

        public_layer = Layer(name=u'__test_public_layer', order=40, public=True)
        public_layer.isChecked = False

        private_layer = Layer(name=u'__test_private_layer', order=40, public=False)
        private_layer.geoTable = 'a_schema.a_geo_table'

        layer_in_group = Layer(name=u'__test_layer_in_group')
        layer_group = LayerGroup(name=u'__test_layer_group')
        layer_group.children = [layer_in_group]

        layer_wmsgroup = Layer(name=u'test_wmsfeaturesgroup')
        layer_wmsgroup.isChecked = False

        theme = Theme(name=u'__test_theme')
        theme.children = [public_layer, private_layer, layer_group,
                layer_wmsgroup]

        poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"

        area = WKTSpatialElement(poly, srid=21781)
        RestrictionArea(name=u'__test_ra1', description=u'',
                             layers=[private_layer],
                             roles=[role1], area=area)

        area = WKTSpatialElement(poly, srid=21781)
        RestrictionArea(
            name=u'__test_ra2', description=u'',
            layers=[private_layer],
            roles=[role2], area=area, readwrite=True
        )

        DBSession.add_all([user1, user2, public_layer, private_layer])

        transaction.commit()
    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_noscale = LayerWMS(name=u"__test_layer_noscale", public=True)
        layer_noscale.layer = "test_noscale"
        layer_noscale.interfaces = [main]
        layer_noscale.ogc_server = ogc_server

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

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

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

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

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

        DBSession.add_all([theme])

        transaction.commit()
    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, OGCServer, LayerWMS

        main = Interface(name=u"main")

        ogc_server = OGCServer(name="__test_ogc_server", type="mapserver", image_type="image/jpeg")

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

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

        layer_wms_3 = LayerWMS(name=u"__test_layer_wms_3", public=True)
        layer_wms_3.layer = "testpoint_unprotected,testpoint_substitution"
        layer_wms_3.interfaces = [main]
        layer_wms_3.ogc_server = ogc_server

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

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

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

        DBSession.add(theme)
        transaction.commit()
Example #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

        main = Interface(name=u"main")

        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()
Example #12
0
    def setUp(self):
        self.config = testing.setUp()

        from c2cgeoportal.models import DBSession, User, Role, Layer, RestrictionArea, Theme, LayerGroup

        role1 = Role(name=u"__test_role1")
        user1 = User(username=u"__test_user1", password=u"__test_user1", role=role1)

        role2 = Role(name=u"__test_role2")
        user2 = User(username=u"__test_user2", password=u"__test_user2", role=role2)

        public_layer = Layer(name=u"__test_public_layer", order=40, public=True)
        public_layer.isChecked = False

        private_layer = Layer(name=u"__test_private_layer", order=40, public=False)
        private_layer.geoTable = "a_schema.a_geo_table"

        layer_in_group = Layer(name=u"__test_layer_in_group")
        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [layer_in_group]

        theme = Theme(name=u"__test_theme")
        theme.children = [public_layer, private_layer, layer_group]

        poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"

        area = WKTSpatialElement(poly, srid=21781)
        ra = RestrictionArea(name=u"__test_ra1", description=u"", layers=[private_layer], roles=[role1], area=area)

        area = WKTSpatialElement(poly, srid=21781)
        ra = RestrictionArea(
            name=u"__test_ra2", description=u"", layers=[private_layer], roles=[role2], area=area, readwrite=True
        )

        DBSession.add_all([user1, user2, public_layer, private_layer])

        transaction.commit()
Example #13
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()
    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, Interface, LayerGroup

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

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

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

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

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

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

        desktop_only_group = LayerGroup(name=u"__test_desktop_only_layer_group")
        desktop_only_group.children = [layer]
        desktop_only_theme = Theme(name=u"__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=u"__test_mobile_private_layer_group")
        mobile_private_group.children = [layer]
        mobile_private_theme = Theme(name=u"__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()
Example #15
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, LayerWMTS, Dimension

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

        layer_wms_1 = LayerWMS(name=u"__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=u"__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=u"__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=u"__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=u"__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_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.interfaces = [main]
        Dimension("B", "b", layer_wmts)

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

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

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

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

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

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

        theme = Theme(name=u"__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()
    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()
Example #17
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, LayerWMTS, Dimension

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

        layer_wms_1 = LayerWMS(name=u"__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=u"__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=u"__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=u"__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=u"__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_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]
        Dimension("B", "b", layer_wmts)

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

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

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

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

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

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

        theme = Theme(name=u"__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()
    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, ServerOGC, LayerWMS, UIMetadata

        desktop = Interface(name=u"desktop")

        server_ogc_internal = ServerOGC(name="__test_server_ogc_internal", type="mapserver", image_type="image/png")

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

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

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

        DBSession.add(theme)

        transaction.commit()
Example #19
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, Functionality, Interface, \
            LayerV1, ServerOGC, LayerWMS, LayerWMTS, \
            UIMetadata, WMTSDimension

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

        layer_v1 = LayerV1(name=u"__test_layer_v1", public=True)
        layer_v1.interfaces = [main]
        layer_v1.ui_metadatas = [UIMetadata("test", "v1")]

        server_ogc_internal = ServerOGC(name="__test_server_ogc_internal", type="mapserver", image_type="image/jpeg")
        server_ogc_external = ServerOGC(name="__test_server_ogc_external", url="internal_url", image_type="image/jpeg")

        layer_internal_wms = LayerWMS(name=u"__test_layer_internal_wms", public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main, min_levels]
        layer_internal_wms.ui_metadatas = [UIMetadata("test", "internal_wms")]
        layer_internal_wms.server_ogc = server_ogc_internal

        layer_external_wms = LayerWMS(name=u"__test_layer_external_wms", public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.ui_metadatas = [UIMetadata("test", "external_wms")]
        layer_external_wms.server_ogc = server_ogc_external

        layer_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.interfaces = [main, mobile]
        layer_wmts.ui_metadatas = [UIMetadata("test", "wmts")]
        layer_wmts.dimensions = [WMTSDimension("year", "2015")]

        layer_group_1 = LayerGroup(name=u"__test_layer_group_1")
        layer_group_1.children = [layer_v1, layer_internal_wms, layer_external_wms, layer_wmts]
        layer_group_1.ui_metadatas = [UIMetadata("test", "group_1")]

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

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

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

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

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

        DBSession.add_all([theme, theme_layer])

        transaction.commit()
Example #20
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, Functionality, Interface, \
            LayerV1, LayerInternalWMS, LayerExternalWMS, LayerWMTS, \
            UIMetadata, WMTSDimension

        main = Interface(name=u'main')
        mobile = Interface(name=u'mobile')
        min_levels = Interface(name=u'min_levels')

        layer_v1 = LayerV1(name=u'__test_layer_v1', public=True)
        layer_v1.interfaces = [main]
        layer_v1.ui_metadata = [UIMetadata('test', 'v1')]
        layer_internal_wms = LayerInternalWMS(name=u'__test_layer_internal_wms', public=True)
        layer_internal_wms.layer = "__test_layer_internal_wms"
        layer_internal_wms.interfaces = [main, min_levels]
        layer_internal_wms.ui_metadata = [UIMetadata('test', 'internal_wms')]
        layer_external_wms = LayerExternalWMS(name=u'__test_layer_external_wms', public=True)
        layer_external_wms.interfaces = [main]
        layer_external_wms.ui_metadata = [UIMetadata('test', 'external_wms')]
        layer_wmts = LayerWMTS(name=u'__test_layer_wmts', public=True)
        layer_wmts.interfaces = [main, mobile]
        layer_wmts.ui_metadata = [UIMetadata('test', 'wmts')]
        layer_wmts.dimensions = [WMTSDimension('year', '2015')]

        layer_group_1 = LayerGroup(name=u'__test_layer_group_1')
        layer_group_1.children = [layer_v1, layer_internal_wms, layer_external_wms, layer_wmts]
        layer_group_1.ui_metadata = [UIMetadata('test', 'group_1')]

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

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

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

        theme = Theme(name=u'__test_theme')
        theme.interfaces = [main, mobile]
        theme.ui_metadata = [UIMetadata('test', 'theme')]
        theme.children = [
            layer_group_1, layer_group_2
        ]
        theme_layer = Theme(name=u'__test_theme_layer')
        theme_layer.interfaces = [min_levels]
        theme_layer.children = [
            layer_internal_wms
        ]

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

        DBSession.add_all([theme, theme_layer])

        transaction.commit()
Example #21
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, LayerWMTS

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

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

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

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

        layer_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.interfaces = [main]

        layer_wms_group = LayerWMS(name=u"__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=u"__test_layer_group_1")
        layer_group_1.children = [layer_wms_1, layer_wms_2]

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

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

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

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

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

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

        theme = Theme(name=u"__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()
Example #22
0
    def setUp(self):
        from c2cgeoportal.models import DBSession, Layer, Theme

        layer = Layer(name=u'__test_layer')

        mobile_only_layer = Layer(name=u'__test_mobile_only_layer')
        mobile_only_layer.inDesktopViewer = False

        desktop_only_layer = Layer(name=u'__test_desktop_only_layer')
        desktop_only_layer.inMobileViewer = False

        theme = Theme(name=u'__test_theme')
        theme.children = [layer, mobile_only_layer, desktop_only_layer]
        theme.inMobileViewer = True

        mobile_only_theme = Theme(name=u'__test_mobile_only_theme')
        mobile_only_theme.children = [layer]
        mobile_only_theme.inDesktopViewer = False
        mobile_only_theme.inMobileViewer = True

        desktop_only_theme = Theme(name=u'__test_desktop_only_theme')
        desktop_only_theme.children = [layer]
        desktop_only_theme.inMobileViewer = False

        # 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_theme = Theme(name=u'__test_mobile_private_theme')
        mobile_private_theme.children = [layer]
        mobile_private_theme.inDesktopViewer = False
        mobile_private_theme.inMobileViewer = False

        DBSession.add_all([
            layer, mobile_only_layer, desktop_only_layer, theme,
            mobile_only_theme, desktop_only_theme, mobile_private_theme
        ])
        transaction.commit()
Example #23
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, Functionality, Interface, \
            LayerV1, OGCServer, LayerWMS, LayerWMTS, \
            Metadata, Dimension, OGCSERVER_AUTH_NOAUTH

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

        layer_v1 = LayerV1(name=u"__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=u"__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=u"__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=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, mobile]
        layer_wmts.metadatas = [Metadata("test", "wmts")]
        layer_wmts.dimensions = [Dimension("year", "2015")]

        layer_group_1 = LayerGroup(name=u"__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=u"__test_layer_group_2")
        layer_group_2.children = [layer_wmts, layer_internal_wms, layer_external_wms]

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

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

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

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

        DBSession.add_all([theme, theme_layer])

        transaction.commit()
Example #24
0
    def setUp(self):
        from c2cgeoportal.models import DBSession, Layer, Theme

        layer = Layer(name=u'__test_layer')

        mobile_only_layer = Layer(name=u'__test_mobile_only_layer')
        mobile_only_layer.inDesktopViewer = False

        desktop_only_layer = Layer(name=u'__test_desktop_only_layer')
        desktop_only_layer.inMobileViewer = False

        theme = Theme(name=u'__test_theme')
        theme.children = [layer, mobile_only_layer, desktop_only_layer]
        theme.inMobileViewer = True

        mobile_only_theme = Theme(name=u'__test_mobile_only_theme')
        mobile_only_theme.children = [layer]
        mobile_only_theme.inDesktopViewer = False
        mobile_only_theme.inMobileViewer = True

        desktop_only_theme = Theme(name=u'__test_desktop_only_theme')
        desktop_only_theme.children = [layer]
        desktop_only_theme.inMobileViewer = False

        # 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_theme = Theme(name=u'__test_mobile_private_theme')
        mobile_private_theme.children = [layer]
        mobile_private_theme.inDesktopViewer = False
        mobile_private_theme.inMobileViewer = False

        DBSession.add_all([
            layer, mobile_only_layer, desktop_only_layer, theme,
            mobile_only_theme, desktop_only_theme, mobile_private_theme
        ])
        transaction.commit()