|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 | from converter.cisu.resources_info.resources_info_cisu_converter import ( |
| 8 | + ConversionError, |
8 | 9 | ResourcesInfoCISUConverter, |
9 | 10 | ) |
10 | 11 | from tests.constants import TestConstants |
@@ -120,21 +121,21 @@ def test_keep_latest_state_should_keep_latest(self): |
120 | 121 | {"datetime": "2025-01-02T08:00:00Z"}, |
121 | 122 | ] |
122 | 123 | } |
123 | | - ResourcesInfoCISUConverter.keep_last_state(resource) |
| 124 | + ResourcesInfoCISUConverter._keep_last_state(resource) |
124 | 125 |
|
125 | 126 | expected_resource = {"state": {"datetime": "2025-01-02T12:00:00Z"}} |
126 | 127 |
|
127 | 128 | assert resource == expected_resource |
128 | 129 |
|
129 | 130 | def test_keep_last_state_should_raise_exception_if_state_empty(self): |
130 | | - with pytest.raises(ValueError): |
| 131 | + with pytest.raises(ConversionError): |
131 | 132 | resource = {"state": []} |
132 | | - ResourcesInfoCISUConverter.keep_last_state(resource) |
| 133 | + ResourcesInfoCISUConverter._keep_last_state(resource) |
133 | 134 |
|
134 | 135 | def test_keep_last_state_should_raise_exception_if_state_undefined(self): |
135 | | - with pytest.raises(ValueError): |
| 136 | + with pytest.raises(ConversionError): |
136 | 137 | resource = {} |
137 | | - ResourcesInfoCISUConverter.keep_last_state(resource) |
| 138 | + ResourcesInfoCISUConverter._keep_last_state(resource) |
138 | 139 |
|
139 | 140 |
|
140 | 141 | def test_cisu_to_rs_breaking_changes(): |
@@ -164,16 +165,26 @@ def test_cisu_to_rs_breaking_changes(): |
164 | 165 | pytest.param("SIS.DRAGON", "SIS", id="translates SIS.DRAGON to SIS"), |
165 | 166 | pytest.param("SMUR", "SMUR", id="translates SMUR to SMUR"), |
166 | 167 | pytest.param("SMUR.VLM", "SMUR", id="translates SMUR.VLM to SMUR"), |
167 | | - pytest.param("AUTREVEC", None, id="AUTREVEC is not mappable to CISU"), |
168 | | - pytest.param("FSI.HELIFSI ", None, id="FSI.HELIFSI is not mappable to CISU"), |
169 | | - pytest.param("TSU.VSL", None, id="TSU.VSL is not mappable to CISU"), |
170 | 168 | ], |
171 | 169 | ) |
172 | 170 | def test_translate_vehicule_type_to_cisu(rs_vehicule_type, expected): |
173 | | - cisu_vehicle_type = ResourcesInfoCISUConverter.translate_to_cisu_vehicle_type( |
174 | | - rs_vehicule_type |
175 | | - ) |
176 | | - assert cisu_vehicle_type == expected |
| 171 | + resource = {"vehicleType": rs_vehicule_type} |
| 172 | + ResourcesInfoCISUConverter._translate_to_cisu_vehicle_type(resource) |
| 173 | + assert resource["vehicleType"] == expected |
| 174 | + |
| 175 | + |
| 176 | +@pytest.mark.parametrize( |
| 177 | + "rs_vehicule_type", |
| 178 | + [ |
| 179 | + pytest.param("AUTREVEC", id="AUTREVEC is not mappable to CISU"), |
| 180 | + pytest.param("FSI.HELIFSI", id="FSI.HELIFSI is not mappable to CISU"), |
| 181 | + pytest.param("TSU.VSL", id="TSU.VSL is not mappable to CISU"), |
| 182 | + ], |
| 183 | +) |
| 184 | +def test_translate_vehicule_type_to_cisu_raises_on_unmappable(rs_vehicule_type): |
| 185 | + resource = {"vehicleType": rs_vehicule_type} |
| 186 | + with pytest.raises(ConversionError): |
| 187 | + ResourcesInfoCISUConverter._translate_to_cisu_vehicle_type(resource) |
177 | 188 |
|
178 | 189 |
|
179 | 190 | # --------------------------------------------------------------------------- |
|
0 commit comments