Skip to content

Commit

Permalink
Merge pull request #118 from PDOK/fix-unit-tests
Browse files Browse the repository at this point in the history
fix validate dimension function to work correctly
  • Loading branch information
Shalucik authored May 28, 2024
2 parents 4f39994 + dd9894e commit f70a123
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 63 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
python-version: ['3.11', '3.10', '3.9', '3.8', '3.7', '3.6']
gdal-version: ['3.4'] #, '3.6'] TODO: gdal 3.6 is still unstable.
os: [ubuntu-22.04, ubuntu-20.04] # no ubuntugis @ ubuntu-24.04
python-version: ['3.11', '3.10', '3.9', '3.8', '3.7'] # , '3.6'] <- 3.6 needs setup.cfg
gdal-version: ['3.4', '3.6'] # TODO: gdal 3.6 is still unstable.
exclude:
- os: ubuntu-24.04
python-version: '3.8'
- os: ubuntu-24.04
python-version: '3.7'
- os: ubuntu-24.04
gdal-version: '3.4'
- os: ubuntu-22.04
python-version: '3.6'
gdal-version: '3.4'
- os: ubuntu-20.04
python-version: '3.11'
- os: ubuntu-20.04
Expand All @@ -27,6 +33,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: install gdal
id: gdal
run: |
if [ "${{ matrix.os }}" = "ubuntu-20.04" ]
then
Expand All @@ -43,20 +50,16 @@ jobs:
echo "using version ->${APT_GDAL_VERSION}<-"
apt-cache madison libgdal30 | grep "${APT_GDAL_VERSION}" && sudo apt-get install libgdal30="${APT_GDAL_VERSION}"
sudo apt-get install python3-gdal="${APT_GDAL_VERSION}" libgdal-dev="${APT_GDAL_VERSION}"
echo gdal_version=$(echo "${APT_GDAL_VERSION}" | cut -f1 -d '+') >> $GITHUB_OUTPUT
- name: Install dependencies for test
run: |
python -m pip install --upgrade pip wheel
python -m pip install setuptools==57.*
python -m pip freeze
if [ "${{ matrix.python-version }}" == "3.6" ]
then
echo "hack setup.cfg to accomodate python version <= 3.6"
sed -i 's/geopackage_validator.__version__/0.0.0/g' setup.cfg
fi
- name: Install dependencies from config
run: |
# we need to pin GDAL here to match the python3-gdal
pip install GDAL==${{ matrix.gdal-version }}
pip install GDAL==${{steps.gdal.outputs.gdal_version}}
pip3 install --no-cache-dir .[test]
- name: Test with pytest
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ node_modules/
doc/build/
ansible/*.retry
.venv
/venv/
build/

# Unit test / coverage reports
Expand All @@ -33,4 +34,4 @@ coverage.xml

# Docker
docker-compose.override.yml
.env
.env
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ WORKDIR /code

COPY ./geopackage_validator /code/geopackage_validator
COPY ./pyproject.toml /code/pyproject.toml
COPY ./setup.cfg /code/setup.cfg
COPY ./setup.py /code/setup.py

# --- TEST-IMAGE ---
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ ARG GROUP_ID=1000
ARG USER_NAME=pdok
ARG GROUP_NAME=pdok

RUN apk add --update --no-cache py3-pip

RUN addgroup -g $GROUP_ID $GROUP_NAME && \
adduser --shell /sbin/nologin --disabled-password \
--uid $USER_ID --ingroup $GROUP_NAME $USER_NAME
USER $USER_NAME

ENV VIRTUAL_ENV=/home/pdok/venv
RUN python3 -m venv --system-site-packages /home/pdok/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PYTHONUNBUFFERED=1

RUN pip3 install setuptools pip virtualenv --upgrade
COPY --chown=pdok:pdok . /code
WORKDIR /code

RUN . /home/pdok/venv/bin/activate && pip3 install -e .[test]

ADD local_entrypoint.sh /entry/local_entrypoint.sh

ENTRYPOINT [ "/entry/local_entrypoint.sh" ]
8 changes: 6 additions & 2 deletions geopackage_validator/validations/geometry_dimension_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ def query_dimensions(dataset) -> Iterable[Tuple[str, str]]:
validations = dataset.ExecuteSQL(
DIMENSION_QUERY.format(table_name=table_name, geom_column_name=column_name)
)
validation_list = (
[]
if validations is None
else [(z, m, ndims) for z, m, ndims in validations]
)

if validations is not None:
validation_list = [(z, m, ndims) for z, m, ndims in validations]
if validation_list:
four_dimensions = all(ndims == 4 for z, m, ndims in validation_list)
m_coordinates_all_0 = all(m for z, m, ndims in validation_list)
z_coordinates_all_0 = all(z for z, m, ndims in validation_list)
Expand Down
9 changes: 6 additions & 3 deletions local_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env sh

# this entrypoint does just that: make sure the egg-info dir is available by installing (again) with pip.
if [ ! -d ./pdok_geopackage_validator.egg-info/ ]
if [ ! -d /code/pdok_geopackage_validator.egg-info/ ] || [ ! -d /code/venv/ ]
then
pip3 install --no-cache-dir -e .
python3 -m venv --system-site-packages /code/venv
. /code/venv/bin/activate
pip3 install -e .[test]
else
. /code/venv/bin/activate
fi
exec "$@"
23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]
dynamic = ["version", "readme", "requires-python"]
dynamic = ["version", "readme"]
dependencies = [
"setuptools>=42.0,!=58.*,!=59.*,!=60.*,!=61.*",
"Click >= 8.0",
"click-log >=0.3",
"gdal >=3.0.4",
"minio",
"pyyaml",
]
requires-python = ">=3.6"

[project.optional-dependencies]
test = [
"black == 22.3.0",
"flake8",
"ipdb",
"ipython",
"pytest >= 7.0.1",
"pytest-cov",
"pytest-flakes",
"pytest-mock"
]

[project.scripts]
geopackage-validator = "geopackage_validator.cli:cli"
Expand Down
40 changes: 0 additions & 40 deletions setup.cfg

This file was deleted.

0 comments on commit f70a123

Please sign in to comment.