Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Alica committed Nov 20, 2024
1 parent ae5cadc commit 45ff5b4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 83 deletions.
117 changes: 34 additions & 83 deletions .github/workflows/publish-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,11 @@ on:
- 'client-*'

jobs:
# TODO
# Faire des tests
# test:
# runs-on: ubuntu-latest
# steps:
# #----------------------------------------------
# # check-out repo and set-up python
# #----------------------------------------------
# - name: Check out repository
# uses: actions/checkout@v3
# - name: Set up python
# id: setup-python
# uses: actions/setup-python@v4
# with:
# python-version: '3.9'
# #----------------------------------------------
# # ----- install & configure poetry -----
# #----------------------------------------------
# - name: Install Poetry
# uses: snok/install-poetry@v1
# with:
# virtualenvs-create: true
# virtualenvs-in-project: true
# installer-parallel: true

# #----------------------------------------------
# # load cached venv if cache exists
# #----------------------------------------------
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# #----------------------------------------------

# # install dependencies if cache does not exist
# #----------------------------------------------
# - name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# run: poetry install --no-interaction --without dev

# #----------------------------------------------
# # add only pytest for tests (not the full dev dependencies to avoid installing spyder)
# #----------------------------------------------
# - name: Add pytest
# run: poetry run pip install pytest

# #----------------------------------------------
# # add only pytest-cov for tests (not the full dev dependencies to avoid installing spyder)
# #----------------------------------------------
# - name: Add pytest-cov
# run: poetry run pip install pytest-cov

# #----------------------------------------------
# # run test suite
# #----------------------------------------------
# - name: Run tests
# env:
# insee_key: ${{secrets.INSEE_KEY}}
# insee_secret: ${{secrets.INSEE_SECRET}}
# run: poetry run pytest --cov -W error

publish:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-package/cartiflette
# needs: test
steps:
#----------------------------------------------
# check-out repo and set-up python
Expand All @@ -91,32 +27,47 @@ jobs:
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
# with:
# virtualenvs-create: true
# virtualenvs-in-project: true
# installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
# add only pytest for tests (not the full dev dependencies to avoid installing spyder)
#----------------------------------------------
- name: Add pytest
run: poetry run pip install pytest

#----------------------------------------------
# add only pytest-cov for tests (not the full dev dependencies to avoid installing spyder)
#----------------------------------------------
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Add pytest-cov
run: poetry run pip install pytest-cov

#----------------------------------------------
# install dependencies if cache does not exist
# run test suite
#----------------------------------------------
# - name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# run: poetry install --no-interaction --no-root --without dev --extras "full"
- name: Run tests
run: poetry run pytest --cov -W error

publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-package/cartiflette
needs: test
steps:
#----------------------------------------------
# install your root project, if required
# check-out repo and set-up python
#----------------------------------------------
# - name: Install project
# run: poetry install --no-interaction --without dev
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.9'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1

#----------------------------------------------
# config pypi token
Expand Down
25 changes: 25 additions & 0 deletions python-package/cartiflette/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 20 11:15:09 2024
Test cartiflette client
"""

import geopandas as gpd

from cartiflette.client import carti_dataset


def test_carti_dataset():
dataset = carti_dataset(
values=["France"],
crs=4326,
borders="DEPARTEMENT",
vectorfile_format="topojson",
simplification=50,
filter_by="FRANCE_ENTIERE_DROM_RAPPROCHES",
source="EXPRESS-COG-CARTO-TERRITOIRE",
year=2022,
)
assert isinstance(dataset, gpd.GeoDataFrame)

0 comments on commit 45ff5b4

Please sign in to comment.