Пример #1
0
def test_create_address():
    from buycoins import transactions

    _mock_gql(create_address_response)

    created_address = transactions.create_address("litecoin")
    assert isinstance(created_address, transactions.AddressType)
    assert created_address.address == "addr1"
    assert created_address.cryptocurrency == "litecoin"
Пример #2
0
def test_estimate_network_fees():
    from buycoins import transactions

    _mock_gql(estimate_network_fee_response)

    fee = transactions.estimate_network_fee("bitcoin", 0.0234)
    assert isinstance(fee, transactions.NetworkFeeType)
    assert fee.estimated_fee == Decimal("2322.3")
    assert fee.total == Decimal("2342.02")
Пример #3
0
def test_get_balance():
    from buycoins import transactions

    _mock_gql(get_balances_response)

    balance = transactions.get_balance("litecoin")
    assert isinstance(balance, transactions.CoinBalanceType)
    assert balance.cryptocurrency == "litecoin"
    assert balance.id == "3"
Пример #4
0
def test_get_price():
    from buycoins import orders

    _mock_gql(get_prices_response)

    price = orders.get_price("litecoin")
    assert orders.CoinPriceType == type(price)
    assert price.cryptocurrency == "litecoin"
    assert price.id == "2"
    assert price.buy_price_per_coin == Decimal(1993)
Пример #5
0
def test_get_prices():
    from buycoins import orders

    _mock_gql(get_prices_response)

    prices = orders.get_prices()
    assert 3 == len(prices)
    assert all(orders.CoinPriceType == type(price) for price in prices)
    assert prices[0].cryptocurrency == "bitcoin"
    assert prices[0].id == "1"
Пример #6
0
def test_get_market_book():
    from buycoins import p2p
    from buycoins.modules.orders import OrderType

    _mock_gql(get_market_book_response)

    orders, price_expiry = p2p.get_market_book()
    assert price_expiry == "2340782074"
    assert 2 == len(orders)
    assert isinstance(orders[0], OrderType)
Пример #7
0
def test_create_deposit():
    from buycoins import accounts

    _mock_gql(create_deposit_response)

    acc = accounts.create_deposit("john doe")
    assert type(acc) == accounts.VirtualDepositAccountType
    assert acc.account_number == "123"
    assert acc.account_reference == "ref"
    assert acc.account_name == "john doe"
Пример #8
0
def test_get_orders():
    from buycoins import p2p
    from buycoins.modules.orders import OrderType

    _mock_gql(get_orders_response)
    orders, price_expiry = p2p.get_orders(status="active")

    assert price_expiry == "2340782074"
    assert 3 == len(orders)
    assert orders[0].cryptocurrency == "bitcoin"
    assert isinstance(orders[0], OrderType)
    assert all(order.status == "active" for order in orders)
Пример #9
0
def test_get_balances():
    from buycoins import transactions

    _mock_gql(get_balances_response)

    balances = transactions.get_balances()
    assert 3 == len(balances)
    assert all(
        isinstance(bal, transactions.CoinBalanceType) for bal in balances)
    assert balances[0].id == "1"
    assert balances[0].cryptocurrency == "bitcoin"
    assert balances[0].confirmed_balance == Decimal("10.01")
Пример #10
0
def test_buy():
    from buycoins import orders

    _mock_gql(buy_response)

    buy_order = orders.buy(price_id="10",
                           coin_amount=0.3,
                           cryptocurrency="bitcoin")

    assert orders.OrderType == type(buy_order)
    assert buy_order.status == "active"
    assert buy_order.coin_amount == Decimal(0.3)
    assert buy_order.cryptocurrency == "bitcoin"
Пример #11
0
def test_sell():
    from buycoins import orders

    _mock_gql(sell_coin_response)

    resp = orders.sell(price_id="1",
                       coin_amount=0.0510,
                       cryptocurrency="ethereum")

    assert orders.OrderType == type(resp)
    assert resp.coin_amount == Decimal(0.0510)
    assert resp.status == "active"
    assert resp.cryptocurrency == "ethereum"
Пример #12
0
def test_send_cryptocurrency():
    from buycoins import transactions

    _mock_gql(send_crypto_response)

    sent = transactions.send(cryptocurrency="bitcoin",
                             amount=0.3222,
                             address="addr")
    assert isinstance(sent, transactions.SendReturnValueType)
    assert sent.id == "1"
    assert sent.cryptocurrency == "bitcoin"
    assert sent.amount == Decimal("0.3222")
    assert sent.transaction.id == "tx1"
Пример #13
0
def test_post_market_order():
    from buycoins import p2p, orders

    _mock_gql(place_market_order_response)

    order = p2p.place_market_order(side="sell",
                                   coin_amount=0.0123,
                                   cryptocurrency="ethereum")
    assert isinstance(order, orders.OrderType)
    assert order.id == "20"
    assert order.side == "sell"
    assert order.cryptocurrency == "ethereum"
    assert order.price_type is None
    assert order.dynamic_exchange_rate is None
    assert order.static_price is None
Пример #14
0
def test_place_limit_order():
    from buycoins import p2p, orders

    _mock_gql(place_limit_order_response)

    order = p2p.place_limit_order(
        side="buy",
        coin_amount=0.0023,
        cryptocurrency="bitcoin",
        price_type="static",
        static_price=2342.23,
    )
    assert orders.OrderType == type(order)
    assert order.coin_amount == "0.0023"
    assert order.cryptocurrency == "bitcoin"
    assert order.price_type == "static"
    assert order.static_price == "2342.23"