コード例 #1
0
def test_currencypair_from_fakeapi(mocker):
    mocker.patch.dict(Currency._Currency__currencies, dict(), clear=True)
    mocker.patch.dict(CurrencyPair._CurrencyPair__currency_pairs,
                      dict(),
                      clear=True)

    attrs = {
        "get_asset_info.return_value": FAKE_CURENCY_RESPONSE,
        "get_asset_pairs.return_value": FAKE_CURENCYPAIR_RESPONSE,
    }
    fakeapi = mocker.Mock(**attrs)
    Currency.build_from_api(fakeapi)
    fakeapi.get_asset_info.assert_called_once_with()

    CurrencyPair.build_from_api(fakeapi)
    fakeapi.get_asset_info.assert_called_once_with()
    fakeapi.get_asset_pairs.assert_called_once_with()

    assert Currency.all_symbols(unique=False) == {"XZEC", "ZEUR", "XTZ.S"} | {
        "ZEC",
        "EUR",
    }
    assert CurrencyPair.all_symbols(unique=False) == {"XZECZEUR"} | {"ZECEUR"}
    cb = Currency.find("XZEC")
    cq = Currency.find("ZEUR")
    cpr = CurrencyPair.find("XZECZEUR")
    assert cb != cq
    assert cpr.base == cb
    assert cpr.quote == cq
コード例 #2
0
def test_currency_from_fakeapi_empty(mocker):
    mocker.patch.dict(Currency._Currency__currencies, dict(), clear=True)

    attrs = {"get_asset_info.return_value": {}}
    fakeapi = mocker.Mock(**attrs)

    Currency.build_from_api(fakeapi)
    fakeapi.get_asset_info.assert_called_once_with()

    assert Currency.all_symbols() == set()
コード例 #3
0
def test_currency_from_fakeapi_two_currencies(mocker):
    mocker.patch.dict(Currency._Currency__currencies, dict(), clear=True)

    attrs = {"get_asset_info.return_value": FAKE_CURENCY_RESPONSE}
    fakeapi = mocker.Mock(**attrs)

    Currency.build_from_api(fakeapi)
    fakeapi.get_asset_info.assert_called_once_with()

    assert Currency.all_symbols() == {"XZEC", "ZEUR", "XTZ.S"}
    assert Currency.all_symbols(unique=False) == {"XZEC", "ZEUR", "XTZ.S"} | {
        "ZEC",
        "EUR",
        "XTZ.S",
    }