|
5 | 5 | from docassemble.base.core import DAObject |
6 | 6 | from docassemble.AssemblyLine.al_general import ALIndividual |
7 | 7 | from ..efm_client import ProxyConnection, ApiResponse |
8 | | -from ..conversions import parse_case_info, parse_service_contacts |
| 8 | +from ..conversions import choices_and_map, parse_case_info, parse_service_contacts |
9 | 9 |
|
10 | 10 |
|
11 | 11 | class TestConversions(unittest.TestCase): |
@@ -120,3 +120,45 @@ def test_ignore_attorneys(self): |
120 | 120 | self.assertEqual(len(case.attorneys.keys()), 2) |
121 | 121 | self.assertTrue("e650827f-3a2b-4550-b76c-f7d22ed479ff" in case.attorneys.keys()) |
122 | 122 | self.assertTrue("7ff43f9b-53ff-4e6d-9253-e393318549d0" in case.attorneys.keys()) |
| 123 | + |
| 124 | + |
| 125 | +class TestChoicesAndMap(unittest.TestCase): |
| 126 | + def setUp(self): |
| 127 | + self.data = [ |
| 128 | + { |
| 129 | + "code": "169", |
| 130 | + "name": "Probate or Mental Health", |
| 131 | + "ecfcasetype": "CivilCase", |
| 132 | + "procedureremedyinitial": "Not Available", |
| 133 | + "procedureremedysubsequent": "Not Available", |
| 134 | + "damageamountinitial": "Not Available", |
| 135 | + "damageamountsubsequent": "Not Available", |
| 136 | + }, |
| 137 | + { |
| 138 | + "code": "7405", |
| 139 | + "name": "Adoption", |
| 140 | + "ecfcasetype": "CivilCase", |
| 141 | + "procedureremedyinitial": "Not Available", |
| 142 | + "procedureremedysubsequent": "Not Available", |
| 143 | + "damageamountinitial": "Not Available", |
| 144 | + "damageamountsubsequent": "Not Available", |
| 145 | + }, |
| 146 | + ] |
| 147 | + |
| 148 | + def test_choices_and_map_nones(self): |
| 149 | + # As long as nothing throws, we're good. |
| 150 | + choices_and_map(None) |
| 151 | + choices_and_map([]) |
| 152 | + choices_and_map([None, None]) |
| 153 | + choices_and_map(["blah", "blah"]) |
| 154 | + choices_and_map("blah") |
| 155 | + |
| 156 | + # Note: we still fail on empty dicts in the list. No good fallback for that. |
| 157 | + # choices_and_map([{}]) |
| 158 | + |
| 159 | + def test_choices_and_map_success(self): |
| 160 | + choices, code_map = choices_and_map(self.data) |
| 161 | + self.assertEqual(len(choices), 2) |
| 162 | + self.assertEqual(len(code_map), 2) |
| 163 | + self.assertEqual(choices[0], ("169", "Probate or Mental Health")) |
| 164 | + self.assertEqual(code_map["169"]["name"], "Probate or Mental Health") |
0 commit comments