File: TEST.rst

package info (click to toggle)
geoalchemy2 0.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,572 kB
  • sloc: python: 8,731; makefile: 133; sh: 132
file content (112 lines) | stat: -rw-r--r-- 3,105 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
=====
Tests
=====

Test Container
==============

Instead of installing the necessary requirements onto your host machine, the `test_container/` directory contains
instructions for building a docker image with all the necessary requirements for running the tests across all
supported python versions. When you are finished the container and associated data can be removed.

Install and run the container::

    $ ./test_container/build.sh
    $ ./test_container/run.sh

Run the tests inside the container::

    # tox --workdir /output -vv

Remove the container and associated data::

    $ sudo rm -rf test_container/output
    $ docker image rm geoalchemy2
    $ docker system prune


Host System
===========

If you have a Linux system that you want to run the tests on instead of the test container, follow these steps:


Install system dependencies
---------------------------

(instructions for Ubuntu 22.04)

Install PostgreSQL and PostGIS::

    $ sudo apt-get install postgresql postgresql-14-postgis-3 postgresql-14-postgis-3-scripts

Install the Python and PostgreSQL development packages::

    $ sudo apt-get install python3-dev libpq-dev libgeos-dev

Install SpatiaLite::

    $ sudo apt-get install libsqlite3-mod-spatialite

Install MySQL::

    $ sudo apt-get install mysql-client mysql-server default-libmysqlclient-dev

Install the Python dependencies::

    $ pip install -r requirements.txt
    $ pip install psycopg2

Or you can use the Conda environment provided in the `GeoAlchemy2_dev.yml` file.

Set up the PostGIS database
---------------------------

Create the ``gis`` role::

    $ sudo -u postgres psql -c "CREATE ROLE gis PASSWORD 'gis' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;"

Create the ``gis`` database::

    $ sudo -u postgres createdb -E UTF-8 gis
    $ sudo -u postgres psql -d gis -c 'CREATE SCHEMA gis;'
    $ sudo -u postgres psql -c 'GRANT CREATE ON DATABASE gis TO "gis";'
    $ sudo -u postgres psql -d gis -c 'GRANT USAGE,CREATE ON SCHEMA gis TO "gis";'

Enable PostGIS for the ``gis`` database::

    $ sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis;"

With PostGIS 3 enable PostGIS Raster as well::

    $ sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis_raster;"

Set the path to the SpatiaLite module
-------------------------------------

By default the SpatiaLite functional tests are not run. To run them the ``SPATIALITE_LIBRARY_PATH``
environment variable must be set.

For example, on Debian Sid, and relying on the official SpatiaLite Debian package, the path to
the SpatiaLite library is ``/usr/lib/x86_64-linux-gnu/mod_spatialite.so``, so you would use this::

    $ export SPATIALITE_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/mod_spatialite.so"

Set up the MySQL database
-------------------------

Create the ``gis`` role::

    $ sudo mysql -e "CREATE USER 'gis'@'%' IDENTIFIED BY 'gis';"
    $ sudo mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'gis'@'%' WITH GRANT OPTION;"

Create the ``gis`` database::

    $ mysql -u gis --password=gis -e "CREATE DATABASE gis;"

Run Tests
---------

To run the tests::

    $ py.test