|
1 | 1 | from converter.cisu.resources_info.resources_info_cisu_helper import ( |
2 | 2 | enrich_rs_ri_with_rs_srs, |
| 3 | + log_cisu_to_rs_converted_messages_ids, |
3 | 4 | ) |
4 | 5 |
|
5 | 6 |
|
@@ -124,3 +125,58 @@ def test_current_state_and_persisted_rs_sr(): |
124 | 125 | assert result is not None |
125 | 126 | assert result["resource"][0]["state"][0]["status"] == "PENDING" |
126 | 127 | assert result["resource"][1]["state"][0]["status"] == "DONE2" |
| 128 | + |
| 129 | + |
| 130 | +class TestLogCisuToRsConvertedMessagesIds: |
| 131 | + def test_with_rs_ri_and_rs_srs(self, caplog): |
| 132 | + original = {"distributionID": "orig-123"} |
| 133 | + rs_ri = {"distributionID": "ri-456"} |
| 134 | + rs_sr_list = [ |
| 135 | + {"distributionID": "sr-1"}, |
| 136 | + {"distributionID": "sr-2"}, |
| 137 | + ] |
| 138 | + |
| 139 | + with caplog.at_level("INFO"): |
| 140 | + log_cisu_to_rs_converted_messages_ids(original, rs_ri, rs_sr_list) |
| 141 | + |
| 142 | + assert len(caplog.records) == 1 |
| 143 | + assert caplog.records[0].message == ( |
| 144 | + "Converted RC-RI with distributionID orig-123 into RS-RI ri-456 and 2 RS-SR(s) ['sr-1', 'sr-2']" |
| 145 | + ) |
| 146 | + |
| 147 | + def test_without_rs_ri(self, caplog): |
| 148 | + original = {"distributionID": "orig-123"} |
| 149 | + rs_sr_list = [ |
| 150 | + {"distributionID": "sr-1"}, |
| 151 | + ] |
| 152 | + |
| 153 | + with caplog.at_level("INFO"): |
| 154 | + log_cisu_to_rs_converted_messages_ids(original, None, rs_sr_list) |
| 155 | + |
| 156 | + assert len(caplog.records) == 1 |
| 157 | + assert caplog.records[0].message == ( |
| 158 | + "Converted RC-RI with distributionID orig-123 into 1 RS-SR(s) ['sr-1']" |
| 159 | + ) |
| 160 | + |
| 161 | + def test_with_rs_ri_and_no_rs_srs(self, caplog): |
| 162 | + original = {"distributionID": "orig-123"} |
| 163 | + rs_ri = {"distributionID": "ri-456"} |
| 164 | + |
| 165 | + with caplog.at_level("INFO"): |
| 166 | + log_cisu_to_rs_converted_messages_ids(original, rs_ri, []) |
| 167 | + |
| 168 | + assert len(caplog.records) == 1 |
| 169 | + assert caplog.records[0].message == ( |
| 170 | + "Converted RC-RI with distributionID orig-123 into RS-RI ri-456" |
| 171 | + ) |
| 172 | + |
| 173 | + def test_without_rs_ri_and_no_rs_srs(self, caplog): |
| 174 | + original = {"distributionID": "orig-123"} |
| 175 | + |
| 176 | + with caplog.at_level("INFO"): |
| 177 | + log_cisu_to_rs_converted_messages_ids(original, None, []) |
| 178 | + |
| 179 | + assert len(caplog.records) == 1 |
| 180 | + assert caplog.records[0].message == ( |
| 181 | + "Converted RC-RI with distributionID orig-123" |
| 182 | + ) |
0 commit comments