Пример #1
0
def test_pick_rate_from_most_similar_pair_of_rates_by_order_of_providers():
    best = ExchangeRateManager.pick_the_best([
        ExchangeRate(id=1, rate=Decimal(0.02)),
        ExchangeRate(id=2, rate=Decimal(0.72)),
        ExchangeRate(id=3, rate=Decimal(0.74))
    ])

    assert best.id == 2
Пример #2
0
def test_pick_rate_from_pair_of_same_rates_by_order_of_providers():
    best = ExchangeRateManager.pick_the_best([
        ExchangeRate(id=1, rate=Decimal(0.0)),
        ExchangeRate(id=2, rate=Decimal(0.7)),
        ExchangeRate(id=3, rate=Decimal(0.7))
    ])

    assert best.id == 2
Пример #3
0
def test_pick_middle_rate_if_it_exists2():
    best = ExchangeRateManager.pick_the_best([
        ExchangeRate(id=1, provider_id=1, rate=Decimal(1.5)),
        ExchangeRate(id=2, provider_id=2, rate=Decimal(0.5)),
        ExchangeRate(id=3, provider_id=3, rate=Decimal(1.0))
    ])

    assert best.id == 3
Пример #4
0
def test_pick_rate_from_any_provider_if_rates_are_same():
    best = ExchangeRateManager.pick_the_best([
        ExchangeRate(id=1, provider_id=1, rate=Decimal(0.5)),
        ExchangeRate(id=2, provider_id=2, rate=Decimal(0.5)),
        ExchangeRate(id=3, provider_id=3, rate=Decimal(0.5))
    ])

    assert best.id in (1, 2, 3)
def test_pick_rate_from_most_similar_pair_of_rates_by_order_of_providers():
    best = ExchangeRateManager.pick_the_best([Decimal(0.02), Decimal(0.72), Decimal(0.74)])

    assert best == 0.72
def test_pick_rate_from_pair_of_same_rates_by_order_of_providers():
    best = ExchangeRateManager.pick_the_best([Decimal(0.0), Decimal(0.7), Decimal(0.7)])

    assert best == 0.7
def test_pick_middle_rate_if_it_exists2():
    best = ExchangeRateManager.pick_the_best([Decimal(1.5), Decimal(0.5), Decimal(1.0)])

    assert best == 1.0
def test_pick_rate_from_any_provider_if_rates_are_same():
    best = ExchangeRateManager.pick_the_best([Decimal(0.5), Decimal(0.5), Decimal(0.5)])

    assert best == 0.5