Beispiel #1
0
def convert(amount, input_currency, output_currency):
    try:
        converter = Converter(amount, input_currency, output_currency)
        if converter.check_parameters():
            print(json.dumps(converter.convert(), sort_keys=True, indent=4))
        else:
            print("Wrong parameters.")
    except FileNotFoundError:
        print("Cannot find file with currency symbols.")
        exit(-1)
Beispiel #2
0
def convert(amount, input_currency, output_currency=""):
    try:
        converter = Converter(amount, input_currency, output_currency)
        if converter.check_parameters():
            return converter.convert()
        else:
            return problem(400, "Bad Request", "Wrong parameters",
                           "about:blank")
    except FileNotFoundError:
        return problem(400, "Error", "Cannot find file with currency symbols.",
                       "about:blank")
def test_check_parameters(input_currency, output_currency, expected):
    from src.converter import Converter
    converter = Converter(0, input_currency, output_currency)

    assert converter.check_parameters() == expected