add test to show the failure

This commit is contained in:
Glandos 2022-07-10 15:21:56 +02:00
parent b32abadd05
commit 7a55fb23fa

View file

@ -382,6 +382,13 @@ class TestCurrencyConverter(unittest.TestCase):
result = self.converter.exchange_currency(100, "USD", "EUR")
self.assertEqual(result, 80.0)
def test_failing_remote(self):
with patch("requests.Response.json", new=lambda _: {}):
# we need a non-patched converter, but it seems that MagickMock
# is mocking EVERY instance of the class method. Too bad.
rates = CurrencyConverter.get_rates(self.converter)
self.assertDictEqual(rates, {CurrencyConverter.no_currency: 1})
if __name__ == "__main__":
unittest.main()