def test_storage_estimate_all(ngw_env, ngw_resource_group, ngw_webtest_app, ngw_auth_administrator): with transaction.manager: res = vector_layer('test-vector-layer', ngw_resource_group) DBSession.flush() DBSession.expunge(res) feature = dict(geom='POINT (0 0)') ngw_webtest_app.post_json('/api/resource/%d/feature/' % res.id, feature) content = 'some-content' resp = ngw_webtest_app.put('/api/component/file_upload/', content) file_upload = resp.json ngw_webtest_app.post_json( '/api/resource/%d/feature/%d/attachment/' % (res.id, 1), dict(file_upload=file_upload)) ngw_webtest_app.post('/api/component/pyramid/estimate_storage', status=200) sleep(0.05) # Give a chance to start a thread and acquire the lock with transaction.manager: # Wait estimation end DBSession.execute(SQL_LOCK) cur = ngw_env.core.query_storage( dict(resource_id=lambda col: col == res.id)) assert FeatureAttachmentData.identity in cur assert cur[FeatureAttachmentData.identity]['data_volume'] == len(content) with transaction.manager: DBSession.delete(res)
def initialize_db(self): result = DBSession.execute(''' -- change column type from POINT to POINTZ ALTER TABLE groza_events ALTER COLUMN location TYPE geometry(PointZ) USING ST_Force_3D(location); -- set SRID for geometry column SELECT UpdateGeometrySRID('groza_events','location', 4326); ''')
def test_postgres_version(ngw_txn): """ Useless PostgreSQL version check """ version = LooseVersion(DBSession.execute('SHOW server_version').scalar()) assert version >= LooseVersion('9.3')
def test_postgis_version(ngw_txn): """ Useless PostgreGIS version check """ version = LooseVersion( DBSession.execute('SELECT PostGIS_Lib_Version()').scalar()) assert version >= LooseVersion('2.1.2')
def rewind(ctx): DBSession.execute(""" DELETE FROM setting WHERE component = 'core' AND name = 'instance_id'; """)
def test_postgres_version(ngw_txn): """ Useless PostgreSQL version check """ raw = DBSession.execute(text('SHOW server_version')).scalar() if m := re.search(r'\d+(?:\.\d){1,}', raw): version = Version(m.group(0))
def test_postgis_version(ngw_txn): """ Useless PostgreGIS version check """ version = Version( DBSession.execute(text('SELECT PostGIS_Lib_Version()')).scalar()) assert version >= Version('2.5.0')