def test_type_excinfo(currency, max_num_brunches): num_brunches = randint(1, max_num_brunches) excinfo = get_best_exchange_rate(currency, num_brunches) assert type(excinfo[0]) == tuple assert type(excinfo[0][0]) == str assert type(excinfo[0][1]) == str assert type(excinfo[0][2]) == float
def test_type_of_elems_in_turple(currency, num_branches): excinfo = get_best_exchange_rate(currency, num_branches) for elem in excinfo: assert type(elem) == tuple assert type(elem[0]) == str assert type(elem[1]) == str assert type(elem[2]) == float
def test_sorted(currency, num_branches): excinfo = get_best_exchange_rate(currency, num_branches) sorted_in_f = [] for elem in excinfo: sorted_in_f.append(elem[2]) assert sorted_in_f == sorted(sorted_in_f)
def test_type_num_branches(currency, num_branches): with pytest.raises(ValueError) as excinfo: excinfo = get_best_exchange_rate(currency, num_branches) assert str(excinfo.value) == 'num_branches is uncorrect type'
def test_correct_currency(currency, num_branches): with pytest.raises(ValueError) as excinfo: excinfo = get_best_exchange_rate(currency, num_branches) assert str(excinfo.value) == 'There is now such currency'
def test_peak_num_branches(currency, num_branches): with pytest.raises(IndexError) as excinfo: num_branches = num_branches + 10000 excinfo = get_best_exchange_rate(currency, num_branches) assert str(excinfo.value) == 'Num of brunces is too big'
def test_correct_work(currency, max_num_branches): num_branches = randint(1, max_num_branches) assert len(get_best_exchange_rate(currency, num_branches)) == num_branches
def test_correct_num_brunches(currency): num_brunches = random.uniform(1.00, 13.00) with pytest.raises(ValueError) as excinfo: excinfo = get_best_exchange_rate(currency, num_brunches) assert "Num branches is not correct \nHINT: Num branches must be more then zero and type int" == str( excinfo.value)
def test_sort_correct(currency, max_num_brunches): num_brunches = randint(1, max_num_brunches) excinfo = get_best_exchange_rate(currency, num_brunches) assert excinfo == sorted(excinfo, key=lambda tup: tup[2])
def test_size_of_ans_correct(currency, num_brunches): with pytest.raises(IndexError) as excinfo: excinfo = get_best_exchange_rate(currency, num_brunches + 10000) assert "Num of brunces is too big" == str(excinfo.value)
def test_size_of_ans(currency, max_num_brunches): num_brunches = randint(1, max_num_brunches) assert len(get_best_exchange_rate(currency, num_brunches)) == num_brunches