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"
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")
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"
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)
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"
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)
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"
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)
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")
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"
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"
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"
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
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"