Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCaha committed Jul 16, 2024
1 parent 48f7085 commit 48f61d5
Show file tree
Hide file tree
Showing 11 changed files with 373 additions and 753 deletions.
163 changes: 0 additions & 163 deletions tests/AlgorithmTestCase.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/classes/test_sampling_distance_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from los_tools.classes.sampling_distance_matrix import SamplingDistanceMatrix
from los_tools.constants.field_names import FieldNames
from tests.AlgorithmTestCase import QgsProcessingAlgorithmTestCase


def test_creation(table_angle_distance_size: QgsVectorLayer):
Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ def horizon_line_local() -> QgsVectorLayer:
return _vector_layer(data_file_path("horizon_line_local.gpkg"))


@pytest.fixture
@clean_qgis_layer
def horizon_line_global() -> QgsVectorLayer:
return _vector_layer(data_file_path("horizon_line_global.gpkg"))


@pytest.fixture
@clean_qgis_layer
def layer_point() -> QgsVectorLayer:
Expand All @@ -176,3 +182,15 @@ def layer_points() -> QgsVectorLayer:
@clean_qgis_layer
def layer_points_epsg5514() -> QgsVectorLayer:
return _vector_layer(data_file_path("points_epsg_5514.gpkg"))


@pytest.fixture
@clean_qgis_layer
def layer_size_distance() -> QgsVectorLayer:
return _vector_layer(data_file_path("size_distance.xlsx"))


@pytest.fixture
@clean_qgis_layer
def layer_points_in_direction() -> QgsVectorLayer:
return _vector_layer(data_file_path("points_in_direction.gpkg"))
8 changes: 8 additions & 0 deletions tests/custom_assertions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Optional

from qgis.core import (
Qgis,
QgsCoordinateReferenceSystem,
QgsProcessingAlgorithm,
QgsProcessingContext,
Expand All @@ -27,6 +28,7 @@ def assert_parameter(
default_value: Optional[Any] = None,
parent_parameter: Optional[str] = None,
data_type: Optional[int] = None,
source_type: Optional[Qgis.ProcessingSourceType] = None,
) -> None:
if parameter_type != parameter.type():
raise AssertionError(f"QgsProcessingParameter type error: {parameter_type} != {parameter.type()}.")
Expand All @@ -47,6 +49,12 @@ def assert_parameter(
if data_type != parameter.dataType():
raise AssertionError(f"QgsProcessingParameter data type error: {data_type} != {parameter.dataType()}.")

if source_type is not None:
if source_type != parameter.sourceType():
raise AssertionError(
f"QgsProcessingParameter source type error: {source_type} != {parameter.sourceType()}."
)


def assert_check_parameter_values(alg: QgsProcessingAlgorithm, parameters: Dict) -> None:
can_run, param_check_msg = alg.checkParameterValues(parameters=parameters, context=QgsProcessingContext())
Expand Down
10 changes: 1 addition & 9 deletions tests/processing/create_los/test_tool_create_local_los.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import pytest
from qgis.core import (
Qgis,
QgsFeatureRequest,
QgsProcessingContext,
QgsProcessingFeedback,
QgsRasterLayer,
QgsVectorLayer,
)
from qgis.core import Qgis, QgsFeatureRequest, QgsRasterLayer, QgsVectorLayer

from los_tools.constants.field_names import FieldNames
from los_tools.processing.create_los.tool_create_local_los import CreateLocalLosAlgorithm
from tests.AlgorithmTestCase import QgsProcessingAlgorithmTestCase
from tests.custom_assertions import (
assert_algorithm,
assert_check_parameter_values,
Expand Down
Loading

0 comments on commit 48f61d5

Please sign in to comment.