Exemple #1
0
    def _create_table(self, tablename):
        """ Test functions use this function to create a table object.
        Each test function should call this function only once. And
        there should not be two test functions that call this function
        with the same ptable_name value.
        """
        import sqlahelper
        from sqlalchemy import Table, Column, ForeignKey, types
        from sqlalchemy.orm import sessionmaker
        from sqlalchemy.ext.declarative import declarative_base
        from geoalchemy2 import Geometry, func

        engine = sqlahelper.get_engine()
        Base = declarative_base(bind=engine)  # noqa
        session = sessionmaker(bind=engine)()
        postgis_version = session.execute(func.postgis_version()).scalar()
        management = postgis_version.startswith("1.")

        if self._tables is None:
            self._tables = []

        ctable = Table("%s_child" % tablename,
                       Base.metadata,
                       Column("id", types.Integer, primary_key=True),
                       Column("name", types.Unicode),
                       schema="public")
        ctable.create()
        self._tables.append(ctable)

        ptable = Table(tablename,
                       Base.metadata,
                       Column("id", types.Integer, primary_key=True),
                       Column("child1_id", types.Integer,
                              ForeignKey("public.%s_child.id" % tablename)),
                       Column("child2_id", types.Integer,
                              ForeignKey("public.%s_child.id" % tablename)),
                       Column("point", Geometry("POINT",
                                                management=management)),
                       Column("linestring",
                              Geometry("LINESTRING", management=management)),
                       Column("polygon",
                              Geometry("POLYGON", management=management)),
                       Column("multipoint",
                              Geometry("MULTIPOINT", management=management)),
                       Column(
                           "multilinestring",
                           Geometry("MULTILINESTRING", management=management)),
                       Column("multipolygon",
                              Geometry("MULTIPOLYGON", management=management)),
                       schema="public")
        ptable.create()
        self._tables.append(ptable)

        self.metadata = Base.metadata
    def _create_table(self, tablename):
        """ Test functions use this function to create a table object.
        Each test function should call this function only once. And
        there should not be two test functions that call this function
        with the same ptable_name value.
        """
        import sqlahelper
        from sqlalchemy import Table, Column, ForeignKey, types
        from sqlalchemy.orm import sessionmaker
        from sqlalchemy.ext.declarative import declarative_base
        from geoalchemy2 import Geometry, func

        engine = sqlahelper.get_engine()
        Base = declarative_base(bind=engine)  # noqa
        session = sessionmaker(bind=engine)()
        postgis_version = session.execute(func.postgis_version()).scalar()
        management = postgis_version.startswith("1.")

        if self._tables is None:
            self._tables = []

        ctable = Table(
            "{0!s}_child".format(tablename), Base.metadata,
            Column("id", types.Integer, primary_key=True),
            Column("name", types.Unicode),
            schema="public"
        )
        ctable.create()
        self._tables.append(ctable)

        ptable = Table(
            tablename, Base.metadata,
            Column("id", types.Integer, primary_key=True),
            Column(
                "child1_id", types.Integer,
                ForeignKey("public.{0!s}_child.id".format(tablename))
            ),
            Column(
                "child2_id", types.Integer,
                ForeignKey("public.{0!s}_child.id".format(tablename))
            ),
            Column("point", Geometry("POINT", management=management)),
            Column("linestring", Geometry("LINESTRING", management=management)),
            Column("polygon", Geometry("POLYGON", management=management)),
            Column("multipoint", Geometry("MULTIPOINT", management=management)),
            Column("multilinestring", Geometry("MULTILINESTRING", management=management)),
            Column("multipolygon", Geometry("MULTIPOLYGON", management=management)),
            schema="public"
        )
        ptable.create()
        self._tables.append(ptable)

        self.metadata = Base.metadata
Exemple #3
0
    "LayerV1", "OGCServer",
    "LayerWMS", "LayerWMTS", "Interface", "Metadata", "Dimension",
    "LayergroupTreeitem"
]

log = logging.getLogger(__name__)

Base = sqlahelper.get_base()
DBSession = sqlahelper.get_session()

DBSessions = {
    "dbsession": DBSession,
}

try:
    postgis_version = DBSession.execute(func.postgis_version()).scalar()
except UnboundExecutionError:  # pragma: no cover - needed by non functional tests
    postgis_version = "2.0"
management = postgis_version.startswith("1.")

AUTHORIZED_ROLE = "role_admin"

if schema is not None:
    _schema = schema
else:  # pragma: no cover
    raise Exception(
        "schema not specified, you need to add it to your config"
    )
_parentschema = parentschema

if srid is not None:
Exemple #4
0
    "TreeGroup", "LayerGroup", "Theme", "Layer", "RestrictionArea", "LayerV1",
    "OGCServer", "LayerWMS", "LayerWMTS", "Interface", "Metadata", "Dimension",
    "LayergroupTreeitem"
]

log = logging.getLogger(__name__)

Base = sqlahelper.get_base()
DBSession = sqlahelper.get_session()

DBSessions = {
    "dbsession": DBSession,
}

try:
    postgis_version = DBSession.execute(func.postgis_version()).scalar()
except UnboundExecutionError:  # pragma: no cover - needed by non functional tests
    postgis_version = "2.0"
management = postgis_version.startswith("1.")

AUTHORIZED_ROLE = "role_admin"

if schema is not None:
    _schema = schema
else:  # pragma: no cover
    raise Exception("schema not specified, you need to add it to your config")
_parentschema = parentschema

if srid is not None:
    _srid = srid
else:  # pragma: no cover