def setup_method(self, _): import transaction from sqlalchemy import func from geoalchemy2 import WKTElement from c2cgeoportal_commons.models import DBSession from c2cgeoportal_commons.models.main import FullTextSearch entry1 = FullTextSearch() entry1.label = "label 1" 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 = "label 2" entry2.layer_name = "layer2" entry2.ts = func.to_tsvector("french", "pluie semaine") entry2.the_geom = WKTElement("POINT(-90 -45)", 21781) entry1.public = True entry3 = FullTextSearch() entry3.label = "label 3" entry3.layer_name = "layer2" entry3.ts = func.to_tsvector("french", "vent neige") entry3.the_geom = WKTElement("POINT(-90 -45)", 21781) entry1.public = True DBSession.add_all([entry1, entry2, entry3]) transaction.commit()
def setup_method(self, _): import transaction from sqlalchemy import func from geoalchemy2 import WKTElement from c2cgeoportal_commons.models import DBSession from c2cgeoportal_commons.models.main import FullTextSearch, Role, Interface from c2cgeoportal_commons.models.static import User user1 = User(username="******", password="******") role1 = Role(name="__test_role1", description="__test_role1") user1.role_name = role1.name user2 = User(username="******", password="******") role2 = Role(name="__test_role2", description="__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()
def setup_method(self, _): import transaction from sqlalchemy import func from geoalchemy2 import WKTElement from c2cgeoportal_commons.models import DBSession from c2cgeoportal_commons.models.main import FullTextSearch, Role, Interface from c2cgeoportal_commons.models.static import User role1 = Role(name="__test_role1", description="__test_role1") user1 = User(username="******", password="******", settings_role=role1, roles=[role1]) role2 = Role(name="__test_role2", description="__test_role2") user2 = User(username="******", password="******", settings_role=role2, roles=[role2]) 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", "lausanne") 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", "lausanne") entry6.interface = Interface("main") entry6.public = True # To test the similarity ranking method entry7 = FullTextSearch() entry7.label = "A 7 simi" entry7.ts = func.to_tsvector("french", "A 7 simi") entry7.public = True entry70 = FullTextSearch() entry70.label = "A 70 simi" entry70.ts = func.to_tsvector("french", "A 70 simi") entry70.public = True entry71 = FullTextSearch() entry71.label = "A 71 simi" entry71.ts = func.to_tsvector("french", "A 71 simi") entry71.public = True DBSession.add_all([ user1, user2, role1, role2, entry1, entry2, entry3, entry4, entry5, entry6, entry71, entry70, entry7, ]) transaction.commit()
def setup_method(self, _): # Always see the diff # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff self.maxDiff = None # pylint: disable=invalid-name self._tables = [] from c2cgeoportal_commons.models import DBSession from c2cgeoportal_commons.models.main import Role, \ RestrictionArea, Theme, LayerGroup, Functionality, Interface, \ LayerWMS, OGCServer, FullTextSearch, OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER from c2cgeoportal_commons.models.static import User from sqlalchemy import Column, Table, types, func from sqlalchemy.ext.declarative import declarative_base from geoalchemy2 import Geometry cleanup_db() role1 = Role(name="__test_role1") user1 = User(username="******", password="******", settings_role=role1, roles=[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="******", settings_role=role2, roles=[role2]) main = Interface(name="desktop") mobile = Interface(name="mobile") 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() ogcserver = create_default_ogcserver() private_layer_edit = LayerWMS(name="__test_private_layer_edit", public=False) private_layer_edit.layer = "__test_private_layer" private_layer_edit.geo_table = "a_schema.a_geo_table" private_layer_edit.interfaces = [main, mobile] private_layer_edit.ogc_server = ogcserver public_layer2 = LayerWMS(name="__test_public_layer", layer="__test_public_layer_bis", public=True) public_layer2.interfaces = [main, mobile] public_layer2.ogc_server = ogcserver private_layer = LayerWMS(name="__test_private_layer", layer="__test_private_layer_bis", public=False) private_layer.interfaces = [main, mobile] private_layer.ogc_server = ogcserver interface_not_in_mapfile = Interface(name="interface_not_in_mapfile") public_layer_not_in_mapfile = LayerWMS( name="__test_public_layer_not_in_mapfile", layer="__test_public_layer_not_in_mapfile", public=True) public_layer_not_in_mapfile.interfaces = [interface_not_in_mapfile] public_layer_not_in_mapfile.ogc_server = ogcserver interface_notmapfile = Interface(name="interface_notmapfile") ogcserver_notmapfile = OGCServer(name="__test_ogc_server_notmapfile") ogcserver_notmapfile.url = mapserv_url + "?map=not_a_mapfile" public_layer_not_mapfile = LayerWMS( name="__test_public_layer_notmapfile", layer="__test_public_layer_notmapfile", public=True) public_layer_not_mapfile.interfaces = [interface_notmapfile] public_layer_not_mapfile.ogc_server = ogcserver_notmapfile interface_geoserver = Interface(name="interface_geoserver") 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 public_layer_geoserver = LayerWMS( name="__test_public_layer_geoserver", layer="__test_public_layer_geoserver", public=True) public_layer_geoserver.interfaces = [interface_geoserver] public_layer_geoserver.ogc_server = ogcserver_geoserver interface_no_layers = Interface(name="interface_no_layers") public_layer_no_layers = LayerWMS(name="__test_public_layer_no_layers", public=True) public_layer_no_layers.interfaces = [interface_no_layers] public_layer_no_layers.ogc_server = ogcserver group = LayerGroup(name="__test_layer_group") group.children = [ private_layer_edit, public_layer2, public_layer_not_in_mapfile, public_layer_not_mapfile, public_layer_geoserver, public_layer_no_layers, private_layer ] theme = Theme(name="__test_theme") theme.children = [group] theme.interfaces = [ main, interface_not_in_mapfile, interface_notmapfile, interface_geoserver, interface_no_layers ] functionality1 = Functionality(name="test_name", value="test_value_1") functionality2 = Functionality(name="test_name", value="test_value_2") theme.functionalities = [functionality1, functionality2] poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))" area = WKTElement(poly, srid=21781) RestrictionArea(name="__test_ra1", description="", layers=[private_layer_edit, private_layer], roles=[role1], area=area) area = WKTElement(poly, srid=21781) RestrictionArea(name="__test_ra2", description="", layers=[private_layer_edit, private_layer], roles=[role2], area=area, readwrite=True) 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 = "label1" entry2.layer_name = "layer1" entry2.ts = func.to_tsvector("french", "soleil travail") entry2.the_geom = WKTElement("POINT(-90 -45)", 21781) entry2.public = True entry3 = FullTextSearch() entry3.label = "label1" entry3.layer_name = None entry3.ts = func.to_tsvector("french", "soleil travail") entry3.the_geom = WKTElement("POINT(-90 -45)", 21781) entry3.public = True DBSession.add_all([user1, user2, theme, entry1, entry2, entry3]) DBSession.flush() self.role1_id = role1.id transaction.commit()