mirror of
https://github.com/enzet/map-machine.git
synced 2025-04-29 18:27:19 +02:00
Get use of pytest fixtures.
This commit is contained in:
parent
3bb6439d7b
commit
2a6b5ba350
2 changed files with 28 additions and 12 deletions
|
@ -1,7 +1,8 @@
|
||||||
shapely
|
colour~=0.1.5
|
||||||
numpy>=1.18.1
|
numpy>=1.18.1
|
||||||
portolan~=1.0.1
|
portolan~=1.0.1
|
||||||
|
pytest
|
||||||
pyyaml>=4.2b1
|
pyyaml>=4.2b1
|
||||||
|
shapely
|
||||||
svgwrite~=1.4
|
svgwrite~=1.4
|
||||||
urllib3>=1.25.6
|
urllib3>=1.25.6
|
||||||
colour~=0.1.5
|
|
|
@ -2,7 +2,9 @@
|
||||||
Test icon generation for nodes.
|
Test icon generation for nodes.
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict, Tuple
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from roentgen.icon import IconSet
|
from roentgen.icon import IconSet
|
||||||
from roentgen.grid import IconCollection
|
from roentgen.grid import IconCollection
|
||||||
|
@ -12,21 +14,34 @@ __author__ = "Sergey Vartanov"
|
||||||
__email__ = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
def test_icons() -> None:
|
@pytest.fixture
|
||||||
"""
|
def init_directories() -> Tuple[Path, Path]:
|
||||||
Test grid drawing.
|
"""Create temporary directories."""
|
||||||
"""
|
|
||||||
temp_directory: Path = Path("temp")
|
temp_directory: Path = Path("temp")
|
||||||
temp_directory.mkdir(exist_ok=True)
|
temp_directory.mkdir(exist_ok=True)
|
||||||
|
|
||||||
set_directory: Path = temp_directory / "icon_set"
|
set_directory: Path = temp_directory / "icon_set"
|
||||||
set_directory.mkdir(exist_ok=True)
|
set_directory.mkdir(exist_ok=True)
|
||||||
|
|
||||||
collection: IconCollection = IconCollection.from_scheme(
|
return temp_directory, set_directory
|
||||||
SCHEME, SHAPE_EXTRACTOR
|
|
||||||
)
|
|
||||||
collection.draw_grid(temp_directory / "grid.svg")
|
@pytest.fixture
|
||||||
collection.draw_icons(set_directory)
|
def init_collection() -> IconCollection:
|
||||||
|
"""Create collection of all possible icon sets."""
|
||||||
|
return IconCollection.from_scheme(SCHEME, SHAPE_EXTRACTOR)
|
||||||
|
|
||||||
|
|
||||||
|
def test_grid(init_collection, init_directories) -> None:
|
||||||
|
"""Test grid drawing."""
|
||||||
|
temp_directory, _ = init_directories
|
||||||
|
init_collection.draw_grid(temp_directory / "grid.svg")
|
||||||
|
|
||||||
|
|
||||||
|
def test_icons(init_collection, init_directories) -> None:
|
||||||
|
"""Test individual icons drawing."""
|
||||||
|
_, set_directory = init_directories
|
||||||
|
init_collection.draw_icons(set_directory)
|
||||||
|
|
||||||
|
|
||||||
def get_icon(tags: Dict[str, str]) -> IconSet:
|
def get_icon(tags: Dict[str, str]) -> IconSet:
|
||||||
|
|
Loading…
Add table
Reference in a new issue