From b10b67869429e36d13a27ec1037477c2ecfdd5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Winter-Hu=CC=88benthal?= Date: Wed, 3 May 2023 22:51:48 +0200 Subject: [PATCH] create tests for prepare.py - test default buffer distance - test custom buffer distance - test file creation --- .github/workflows/test-harvest.yml | 25 ++++++++++++++++++++++++ harvester/Dockerfile | 5 +++-- harvester/assets/test/buffer_1000.cpg | 1 + harvester/assets/test/buffer_1000.dbf | Bin 0 -> 78 bytes harvester/assets/test/buffer_1000.prj | 1 + harvester/assets/test/buffer_1000.shp | Bin 0 -> 300 bytes harvester/assets/test/buffer_1000.shx | Bin 0 -> 108 bytes harvester/assets/test/buffer_2000.cpg | 1 + harvester/assets/test/buffer_2000.dbf | Bin 0 -> 78 bytes harvester/assets/test/buffer_2000.prj | 1 + harvester/assets/test/buffer_2000.shp | Bin 0 -> 284 bytes harvester/assets/test/buffer_2000.shx | Bin 0 -> 108 bytes harvester/assets/test/shape.dbf | Bin 0 -> 36 bytes harvester/assets/test/shape.prj | 1 + harvester/assets/test/shape.shp | Bin 0 -> 304 bytes harvester/assets/test/shape.shx | Bin 0 -> 108 bytes harvester/prepare.py | 25 ++++++++++++++---------- harvester/requirements.txt | 8 ++++---- harvester/test_prepare.py | 27 ++++++++++++++++++++++++++ 19 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 harvester/assets/test/buffer_1000.cpg create mode 100644 harvester/assets/test/buffer_1000.dbf create mode 100644 harvester/assets/test/buffer_1000.prj create mode 100644 harvester/assets/test/buffer_1000.shp create mode 100644 harvester/assets/test/buffer_1000.shx create mode 100644 harvester/assets/test/buffer_2000.cpg create mode 100644 harvester/assets/test/buffer_2000.dbf create mode 100644 harvester/assets/test/buffer_2000.prj create mode 100644 harvester/assets/test/buffer_2000.shp create mode 100644 harvester/assets/test/buffer_2000.shx create mode 100644 harvester/assets/test/shape.dbf create mode 100644 harvester/assets/test/shape.prj create mode 100644 harvester/assets/test/shape.shp create mode 100644 harvester/assets/test/shape.shx create mode 100644 harvester/test_prepare.py diff --git a/.github/workflows/test-harvest.yml b/.github/workflows/test-harvest.yml index 0162bc5b..2862389f 100644 --- a/.github/workflows/test-harvest.yml +++ b/.github/workflows/test-harvest.yml @@ -29,6 +29,31 @@ env: # DATABASE_URL: postgresql://fangorn:ent@localhost:5432/trees?schema=public jobs: + test-prepare: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip ci')" + defaults: + run: + working-directory: harvester + steps: + - name: Get the source + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install g++ gdal-bin libgdal-dev libpq-dev -y + - name: Install python packages + run: | + python -m pip install --upgrade pip + python -m pip install --no-cache-dir GDAL==3.4.0 + python -m pip install --no-warn-script-location -r requirements.txt + - name: Test with pytest + run: | + pytest test-harvest: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip ci')" diff --git a/harvester/Dockerfile b/harvester/Dockerfile index f7b0938c..cda5a437 100644 --- a/harvester/Dockerfile +++ b/harvester/Dockerfile @@ -12,14 +12,15 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ENV CPLUS_INCLUDE_PATH=/usr/include/gdal ENV C_INCLUDE_PATH=/usr/include/gdal -# RUN pip install GDAL FROM base as builder # Install pip requirements COPY requirements.txt /app/ -RUN cd /app/ && python -m pip install --no-warn-script-location --prefix=/install -r requirements.txt +RUN python -m pip install --upgrade pip \ + && cd /app/ && python -m pip install --no-warn-script-location --prefix=/install -r requirements.txt \ + && python -m pip install --prefix=/install GDAL==2.4.2 FROM base as app COPY --from=builder /install /usr/local diff --git a/harvester/assets/test/buffer_1000.cpg b/harvester/assets/test/buffer_1000.cpg new file mode 100644 index 00000000..cd89cb97 --- /dev/null +++ b/harvester/assets/test/buffer_1000.cpg @@ -0,0 +1 @@ +ISO-8859-1 \ No newline at end of file diff --git a/harvester/assets/test/buffer_1000.dbf b/harvester/assets/test/buffer_1000.dbf new file mode 100644 index 0000000000000000000000000000000000000000..9ec44fc9dfd0faededac4f848b277c75414c63dd GIT binary patch literal 78 mcmZRsW|3oLU|?`$-~p1Dz|GSICg=xZaKm^|npXh<45R>pt^?8l literal 0 HcmV?d00001 diff --git a/harvester/assets/test/buffer_1000.prj b/harvester/assets/test/buffer_1000.prj new file mode 100644 index 00000000..5c6f76df --- /dev/null +++ b/harvester/assets/test/buffer_1000.prj @@ -0,0 +1 @@ +PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] \ No newline at end of file diff --git a/harvester/assets/test/buffer_1000.shp b/harvester/assets/test/buffer_1000.shp new file mode 100644 index 0000000000000000000000000000000000000000..ae23522612e04d26394d212222171738906bc03b GIT binary patch literal 300 zcmZQzQ0HR64yL_eW?*0i%JJB{GRxPRI!f*2`*dtsw4;LNJ5#Uarj937eYGpsM>}HI zjv~qk5gpoWVP3d9)+@e4bf*yAl3iHY=Lm2Q=@Dah25L71542EspEh RHJUndT#(&e4&pt^?8l literal 0 HcmV?d00001 diff --git a/harvester/assets/test/buffer_2000.prj b/harvester/assets/test/buffer_2000.prj new file mode 100644 index 00000000..5c6f76df --- /dev/null +++ b/harvester/assets/test/buffer_2000.prj @@ -0,0 +1 @@ +PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] \ No newline at end of file diff --git a/harvester/assets/test/buffer_2000.shp b/harvester/assets/test/buffer_2000.shp new file mode 100644 index 0000000000000000000000000000000000000000..907f3360b3cf805d50a6625f0f262b6f737ba4ec GIT binary patch literal 284 zcmZQzQ0HR64*Fg&Gcd3MD;SQL) zN@shfMlX+cyt!{$$*U!%j;D2695|OnJBGb;F1*l%@JAc7%^ux4Q^#*WU<8twfLB353IH030V@Ci literal 0 HcmV?d00001 diff --git a/harvester/assets/test/shape.prj b/harvester/assets/test/shape.prj new file mode 100644 index 00000000..a30c00a5 --- /dev/null +++ b/harvester/assets/test/shape.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/harvester/assets/test/shape.shp b/harvester/assets/test/shape.shp new file mode 100644 index 0000000000000000000000000000000000000000..fddd5ff1106ed0f6c0720979919596d964a0dbe9 GIT binary patch literal 304 zcmZQzQ0HR64raVyW?*0i$^~@CWUmg?bV!iB?3Q8b?O?D@C3k(5rUMW2eMdzrZwKt! zQA8Pmyd+}GVgf4Ugla`re??q&XQhR=!-osbW}8Db9R!j;c*dIn?RMM}XqchtaNyQT zqbWf7g4$Q2g;5B%!Q2kh&+v<1es+SU!vuz9F%^Pk*YpkL9| F0|4HIO=SQ8 literal 0 HcmV?d00001 diff --git a/harvester/assets/test/shape.shx b/harvester/assets/test/shape.shx new file mode 100644 index 0000000000000000000000000000000000000000..9e413aab714079c85fb11f321fe59070895ab34c GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcd3M