Exemplo n.º 1
0
    def test_currency_converter(self):
        converted = currency_converter('USD', 'USD', 1)
        self.assertEqual(converted, '1.00')

        converted = currency_converter('EUR', 'BGN', 1)
        self.assertEqual(converted, '1.96')

        converted = currency_converter('BGN', 'BGN', 1)
        self.assertEqual(converted, '1.00')
Exemplo n.º 2
0
    def test_currency_converter_with_download_new_rates(self):
        basepath = os.path.dirname(__file__)
        now = timezone.now()  # + timedelta(hours=3)
        file_name = "{}.json".format(now.strftime('%Y_%m_%d'))
        rel_filepath = os.path.join(basepath, "..", "tmp", file_name)
        abs_filepath = os.path.abspath(rel_filepath)
        os.remove(abs_filepath)

        converted = currency_converter('USD', 'USD', 1)
        self.assertEqual(converted, '1.00')

        converted = currency_converter('EUR', 'BGN', 1)
        self.assertEqual(converted, '1.96')

        converted = currency_converter('BGN', 'BGN', 1)
        self.assertEqual(converted, '1.00')