Skip to content

Commit

Permalink
Fix test_create_path_bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
tgrandje committed Apr 16, 2024
1 parent bb59699 commit 0b5393a
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,66 @@
import pytest

from cartiflette.utils import create_path_bucket
from cartiflette.config import BUCKET, PATH_WITHIN_BUCKET


@pytest.mark.parametrize(
"config, expected_path",
[
# Teste qu'on substitue bien le bucket à la demande :
(
{"bucket": "my_bucket"},
(
"my_bucket/PATH_WITHIN_BUCKET/2022/"
"administrative_level=COMMUNE/2154/region=28/"
"vectorfile_format=geojson/provider=IGN/"
"source=EXPRESS-COG-TERRITOIRE/raw.geojson"
f"my_bucket/{PATH_WITHIN_BUCKET}/"
"provider=None/dataset_family=None/source=None/year=None/"
"administrative_level=None/crs=2154/None=None/"
"vectorfile_format=None/territory=None/simplification=0/"
"raw.None"
),
),
# Teste qu'on substitue bien le sous-dossier du bucjet à la demande :
(
{"path_within_bucket": "data", "vectorfile_format": "gpkg"},
(
f"{BUCKET}/data/"
"projet-cartiflette/data/provider=None/dataset_family=None/"
"source=None/year=None/administrative_level=None/crs=2154/"
"None=None/vectorfile_format=gpkg/territory=None/"
"simplification=0/raw.gpkg"
),
),
# Teste que pour les shapefiles sans nom on crée bien un dossier :
(
{"vectorfile_format": "shp"},
(
"BUCKET/PATH_WITHIN_BUCKET/2022/"
"administrative_level=COMMUNE/2154/region=28/"
"vectorfile_format=shp/provider=IGN/"
"source=EXPRESS-COG-TERRITOIRE/"
f"{BUCKET}/{PATH_WITHIN_BUCKET}/"
"provider=None/dataset_family=None/source=None/year=None/"
"administrative_level=None/crs=2154/None=None/"
"vectorfile_format=shp/territory=None/simplification=0/"
),
),
# Teste que les arguments intermédiaires fonctionnent bien :
(
{
"year": "2023",
"borders": "DEPARTEMENT",
"crs": 4326,
"filter_by": "REGION",
"year": "2023",
"value": "42",
"crs": 4326,
},
(
"BUCKET/PATH_WITHIN_BUCKET/2023/"
"administrative_level=DEPARTEMENT/4326/REGION=42/"
"geojson/IGN/EXPRESS-COG-TERRITOIRE/raw.geojson"
),
),
(
{"path_within_bucket": "data", "vectorfile_format": "gpkg"},
(
"BUCKET/data/2022/"
"administrative_level=COMMUNE/2154/region=28/"
"gpkg/IGN/EXPRESS-COG-TERRITOIRE/raw.gpkg"
f"{BUCKET}/{PATH_WITHIN_BUCKET}/"
"provider=None/dataset_family=None/source=None/"
"year=2023/"
"administrative_level=DEPARTEMENT/"
"crs=4326/"
"REGION=42/"
"vectorfile_format=None/territory=None/simplification=0/"
"raw.None"
),
),
],
)
def test_create_path_bucket(config, expected_path):
result = create_path_bucket(config)
assert result == expected_path



0 comments on commit 0b5393a

Please sign in to comment.