Skip to content

Commit

Permalink
Test: Test Options attributes separately (#23)
Browse files Browse the repository at this point in the history
# Context

* Regarding issue #15, we need to introduce `options` as a parameter to
validate a given French value.
Previously, options were not tested individually. So, the goal of this
PR is to test options independently, create and test various
combinations to ensure we achieve the desired behavior.

fixes #15
  • Loading branch information
Sarrabah authored Nov 6, 2024
1 parent d6df831 commit bfad0b7
Show file tree
Hide file tree
Showing 39 changed files with 219,677 additions and 219,596 deletions.
2 changes: 1 addition & 1 deletion docs/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| CodePaysISO2 | Codes ISO2 Pays | Code ISO 2 de pays pour un Code Officiel Géographique donné |
| CodePaysISO3 | Codes ISO3 Pays | Code ISO 3 de pays pour un Code Officiel Géographique donné |
| CodePostal | Code postal | Vérifie que le code postal est bien un code postal français |
| CodeRegion | Code région | Vérifie qu'il s'agit d'un code région pour un Code Officiel Géographique donné |
| CodeRegion | Code région | Vérifie qu'il s'agit d'un code région selon le Code Officiel Géographique (cog) donné |
| Commune | Nom de commune | Vérifie que le nom correspond à un nom de commune française pour un Code Officiel Géographique donné(ne vérifie pas l'accentuation, la casse, la ponctuation) |
| CoordonneesGPSFrancaises | Coordonnées GPS françaises | Check that GPS coordinates are in a bounding box approximating France (including DOM) |
| Departement | Nom de département | Vérifie les départements français, collectivités et territoires d'outre-mer valides pour un Code Officiel Géographique donné |
Expand Down
1 change: 1 addition & 0 deletions src/frformat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .geo.numero_departement import NumeroDepartement as NumeroDepartement
from .geo.pays import Pays as Pays
from .geo.region import Region as Region
from .geo_enum_format import Millesime as Millesime
from .nomenclature_acte_format import NomenclatureActe as NomenclatureActe
from .options import Options as Options
from .siren import Siren as Siren
Expand Down
4 changes: 2 additions & 2 deletions src/frformat/enum_format.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Set, Type
from typing import FrozenSet, Type

from frformat import CustomStrFormat, Metadata
from frformat.common import normalize_value
from frformat.options import Options


def new(class_name: str, name: str, description: str, enum: Set[str]) -> Type:
def new(class_name: str, name: str, description: str, enum: FrozenSet[str]) -> Type:
class EnumFormat(CustomStrFormat):
"""Checks if a value is in a given list
Expand Down
10 changes: 5 additions & 5 deletions src/frformat/geo/canton.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Dict, Set
from typing import Dict, FrozenSet

from frformat import geo_enum_format
from frformat.geo.canton_set import CANTON_SET_COG_2023, CANTON_SET_COG_2024
from frformat.geo.canton_frozenset import CANTON_COG_2023, CANTON_COG_2024
from frformat.geo_enum_format import Millesime

name = "Nom de canton"
description = "Vérifie que le nom de canton est un canton ou pseudo-canton français valide pour un Code Officiel Géographique donné"
all_cog_versions: Dict[Millesime, Set[str]] = {
Millesime.A2023: CANTON_SET_COG_2023,
Millesime.A2024: CANTON_SET_COG_2024,
all_cog_versions: Dict[Millesime, FrozenSet[str]] = {
Millesime.A2023: CANTON_COG_2023,
Millesime.A2024: CANTON_COG_2024,
}
Canton = geo_enum_format.new("Canton", name, description, all_cog_versions)
Loading

0 comments on commit bfad0b7

Please sign in to comment.