diff --git a/.github/workflows/tests_mergin_db_sync.yaml b/.github/workflows/tests_mergin_db_sync.yaml new file mode 100644 index 0000000..0f16271 --- /dev/null +++ b/.github/workflows/tests_mergin_db_sync.yaml @@ -0,0 +1,60 @@ +name: Tests for Mergin DB Sync + +on: + push: + paths: + - "test/**" + - "**.py" + - ".github/workflows/tests_mergin_db_sync.yaml" + +env: + TEST_GEODIFF_EXE: geodiff + TEST_DB_CONNINFO: host=localhost dbname=test_db user=postgres password=postgres port=5432 + TEST_MERGIN_URL: https://test.dev.merginmaps.com + TEST_API_USERNAME: test_db_sync + TEST_API_PASSWORD: ${{ secrets.TEST_API_PASSWORD }} + TEST_API_WORKSPACE: test-db-sync + +jobs: + + Tests-for-Mergin-DB-Sync: + + runs-on: ubuntu-latest + + services: + postgres: + image: postgis/postgis:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test_db + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + + - name: Install Geodiff + run: | + sudo apt-get install libsqlite3-dev libpq-dev + git clone https://github.com/MerginMaps/geodiff.git + cd geodiff + mkdir build && cd build + cmake -DWITH_POSTGRESQL=TRUE ../geodiff + sudo make install + sudo cp geodiff /usr/local/bin + + - name: Check Geodiff version + run: geodiff version + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install mergin-client pytest pytest-cov dynaconf psycopg2 + + - name: Checkout + uses: actions/checkout@v2 + + - name: Run tests + run: | + pytest test --cov=. --cov-report=term-missing:skip-covered -vv \ No newline at end of file diff --git a/test/test_basic.py b/test/test_basic.py index 9a35c71..9b2682d 100644 --- a/test/test_basic.py +++ b/test/test_basic.py @@ -202,12 +202,12 @@ def test_init_from_gpkg_with_incomplete_dir(mc: MerginClient): source_gpkg_path = os.path.join(TEST_DATA_DIR, 'base.gpkg') init_project_dir = os.path.join(TMP_DIR, project_name + '_dbsync', project_name) init_sync_from_geopackage(mc, project_name, source_gpkg_path) - assert os.listdir(init_project_dir) == ['test_sync.gpkg', '.mergin'] + assert set(os.listdir(init_project_dir)) == set(['test_sync.gpkg', '.mergin']) shutil.rmtree(init_project_dir) # Remove dir with content os.makedirs(init_project_dir) # Recreate empty project working dir assert os.listdir(init_project_dir) == [] dbsync_init(mc, from_gpkg=True) - assert os.listdir(init_project_dir) == ['test_sync.gpkg', '.mergin'] + assert set(os.listdir(init_project_dir)) == set(['test_sync.gpkg', '.mergin']) def test_basic_pull(mc: MerginClient): diff --git a/test/test_config.py b/test/test_config.py index 955793c..7154dc8 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -71,7 +71,3 @@ def test_config(): config.update({'CONNECTIONS': [{"driver": "postgres", "conn_info": "", "modified": "mergin_main", "base": "mergin_base", "mergin_project": "john/dbsync", "sync_file": "sync.gpkg", "skip_tables":""}]}) validate_config(config) - _reset_config() - with pytest.raises(ConfigError, match="Config error: Ignored tables list can not be empty"): - config.update({'CONNECTIONS': [{"driver": "postgres", "conn_info": "", "modified": "mergin_main", "base": "mergin_base", "mergin_project": "john/dbsync", "sync_file": "sync.gpkg", "skip_tables":[]}]}) - validate_config(config)