Skip to content

Commit

Permalink
Fix tests, rename migration to 1.1.0, switch to Python enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 24, 2023
1 parent 343a18b commit 14b4dc8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
17 changes: 8 additions & 9 deletions netads/processing_netads/data/import_impacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__license__ = "GPL version 3"
__email__ = "[email protected]"

from enum import Enum
from typing import Callable, Dict, List, Tuple, Union

from qgis import processing
Expand Down Expand Up @@ -31,14 +32,12 @@

from netads.processing_netads.data.base import BaseDataAlgorithm

LISTE_TYPE = (
'ZONAGE', 'SERVITUDE', 'PRESCRIPTION', 'INFORMATION',
)

# Impact = namedtuple(
# 'Impact',
# ['type', 'code', 'sous_code', 'etiquette', 'libelle', 'description']
# )
class ListeType(Enum):
Zonage = 'ZONAGE'
Servitude = 'SERVITUDE'
Prescription = 'PRESCRIPTION'
Information = 'INFORMATION'


def sql_error_handler(func: Callable):
Expand Down Expand Up @@ -84,7 +83,7 @@ def shortHelpString(self):
"<br>"
"Le champ pour le 'type' doit contenir exclusivement "
"les valeurs suivantes : "
f"{','.join(LISTE_TYPE)}"
f"{','.join([e.value for e in ListeType])}"
)

# noinspection PyMethodOverriding
Expand All @@ -105,7 +104,7 @@ def initAlgorithm(self, config: Dict):
param = QgsProcessingParameterEnum(
self.TYPE_IMPORT,
"Type d'import",
options=LISTE_TYPE,
options=[e.value for e in ListeType],
optional=False,
)
param.setHelp("Type d'import concernant la couche")
Expand Down
10 changes: 5 additions & 5 deletions netads/processing_netads/data/load_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ def processAlgorithm(
if prefix_parcelle and len(prefix_parcelle) != 3:
# The virtual field needs this variable on runtime.
raise QgsProcessingException(
"Le préfixe parcellaire doit contenir 3 caractères : "
"le code département (2 caractères) + "
"le code de direction (1 caractère). "
f"Le préfixe parcellaire proposé `{prefix_parcelle}` est "
f"de longueur {len(prefix_parcelle)}."
"Le préfixe parcellaire doit contenir 3 caractères : "
"le code département (2 caractères) + "
"le code de direction (1 caractère). "
f"Le préfixe parcellaire proposé `{prefix_parcelle}` est "
f"de longueur {len(prefix_parcelle)}."
)

# Then set variables
Expand Down
1 change: 0 additions & 1 deletion netads/processing_netads/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from qgis.PyQt.QtGui import QIcon

from netads.processing_netads.data.import_communes import ImportCommunesAlg

from netads.processing_netads.data.import_impacts import ImportImpactsAlg
from netads.processing_netads.data.import_parcelles import ImportParcellesAlg
from netads.processing_netads.data.load_layers import LoadLayersAlgorithm
Expand Down
7 changes: 3 additions & 4 deletions netads/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@

import os
import time
import unittest

from unittest import main

import processing

from qgis.core import ( # QgsFeature,; QgsGeometry,; edit,
from qgis.core import (
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsProject,
QgsProviderRegistry,
QgsVectorLayer,
)

from netads.processing_netads.data.import_impacts import LISTE_TYPE
from netads.processing_netads.data.import_impacts import ListeType
from netads.processing_netads.provider import (
NetAdsProvider as ProcessingProvider,
)
Expand All @@ -42,7 +41,7 @@ def test_import_impacts(self):
"ENTREE": str(
plugin_test_data_path("plui", "248000747_INFO_SURF_20201109.shp")
),
"TYPE_IMPORT": LISTE_TYPE[1],
"TYPE_IMPORT": ListeType.Servitude.value,
"CHAMP_CODE": "code",
"CHAMP_SOUS_CODE": "",
"CHAMP_ETIQUETTE": "",
Expand Down
1 change: 0 additions & 1 deletion netads/tests/test_load_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from qgis.core import QgsProcessingContext, QgsProcessingException, QgsProject

from netads.processing_netads.data.load_layers import Key

from netads.tests.base_database import DatabaseTestCase
from netads.tests.feedbacks import FeedbackPrint

Expand Down

0 comments on commit 14b4dc8

Please sign in to comment.