Skip to content

Commit 28509a1

Browse files
Correct mypy issue
A function was marked as returning `Optional`, and it didn't need to be. Also added tests for that function, because I thought I would have to change the actual function.
1 parent 9aecdf4 commit 28509a1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docassemble/ALWeaver/list_taxonomy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_order(prefix: str) -> int:
5151
)
5252

5353
# Define a function to create the desired dictionary for each row
54-
def create_dict(row: pd.Series) -> Optional[Dict[str, str]]:
54+
def create_dict(row: pd.Series) -> Dict[str, str]:
5555
# row["Suffix"] != "-00-00-00-00":
5656
return {
5757
"label": row["Title"],

docassemble/ALWeaver/test_map_names.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# do not pre-load
22
import unittest
3+
import pathlib
34

45
from .interview_generator import map_raw_to_final_display, DAField
6+
from .list_taxonomy import get_LIST_codes
57
from docassemble.base.util import log
68

7-
__all__ = ["TestMapNames"]
9+
__all__ = ["TestMapNames", "TestListTaxonomy"]
810

911
# Some basic test input pdf label strings (left) with desired results (right)
1012
attachment_scenarios = {
@@ -232,5 +234,19 @@ def run_scenarios(self, scenarios, function):
232234
return passed, errored
233235

234236

237+
taxonomy_file = pathlib.Path(__file__).parent / "data" / "sources" / "list-taxonomy.csv"
238+
239+
240+
class TestListTaxonomy(unittest.TestCase):
241+
def setUp(self):
242+
pass
243+
244+
def test_taxonomy(self):
245+
codes = get_LIST_codes(taxonomy_file)
246+
self.assertEqual(len(codes), 224)
247+
self.assertEqual(len(set(c["group"] for c in codes)), 20)
248+
self.assertEqual(len(set(c["label"] for c in codes)), 224)
249+
250+
235251
if __name__ == "__main__":
236252
unittest.main()

0 commit comments

Comments
 (0)