Add documentation.

This commit is contained in:
Sergey Vartanov 2021-05-07 01:34:53 +03:00
parent 0f3888430b
commit e113ef09e4
2 changed files with 19 additions and 5 deletions

View file

@ -95,4 +95,3 @@ def get_text(tags: Dict[str, Any]) -> List[str]:
format_frequency, tags["frequency"].split(";"))))
return texts

View file

@ -1,28 +1,43 @@
"""
Author: Sergey Vartanov (me@enzet.ru).
"""
from typing import List
from roentgen.scheme import Scheme
from roentgen.text import Label
def get_text(tags):
def construct_labels(tags) -> List[Label]:
"""
Construct labels from OSM node tags.
"""
scheme = Scheme("scheme/default.yml")
return scheme.construct_text(tags, True)
def test_1_label() -> None:
labels = get_text({"name": "Name"})
"""
Test tags that should be converted into single label.
"""
labels = construct_labels({"name": "Name"})
assert len(labels) == 1
assert labels[0].text == "Name"
def test_1_label_unknown_tags() -> None:
labels = get_text({"name": "Name", "aaa": "bbb"})
"""
Test tags with some unknown tags that should be converted into single label.
"""
labels = construct_labels({"name": "Name", "aaa": "bbb"})
assert len(labels) == 1
assert labels[0].text == "Name"
def test_2_labels() -> None:
labels = get_text({"name": "Name", "ref": "5"})
"""
Test tags that should be converted into two labels.
"""
labels = construct_labels({"name": "Name", "ref": "5"})
assert len(labels) == 2
assert labels[0].text == "Name"
assert labels[1].text == "5"