#!/usr/bin/env python2
from testlib import register, balance, mine, request, deposit, pay, apicall

ip_address = "vm"
port = "3000"
url = ''.join(['http://', ip_address, ':', port])

def test_page_error():
    r = apicall("nonexistant", "hi")
    assert "error" in r
    assert r["error"] != ""

def test_login(login):
    info = login
    assert 'username' in info
    assert 'secret' in info
    assert len(info.keys()) == 2

def pytest_funcarg__login(request):
    info = register()
    assert 'username' in info
    assert 'secret' in info
    return info

def test_balance(login):
    info = balance(login['username'], login['secret'])
    assert 'balance' in info

def test_request(login):
    info = request(login['username'], login['secret'], amount=1)
    assert 'payment' in info

def test_mine(login):
    info = mine(login['username'], login['secret'])
    info = balance(login['username'], login['secret'])
    assert float(info['balance']) == 0.1

def pytest_funcarg__paidlogin(request, login):
    info = deposit(login['username'], login['secret'])
    assert 'address' in info
    info2 = deposit(login['username'], login['secret'])
    assert info['address'] == info2['address']

    print
    print 'Please send some bitcoins to %s' % info['address']
    print 'Then Hit Enter'
    raw_input()

    info = balance(login['username'], login['secret'])
    assert float(info['balance']) > 0
    return login


def test_deposit(paidlogin):
    info = balance(paidlogin['username'], paidlogin['secret'])
    assert info['balance'] != "0"

def test_payment(paidlogin):
    info = request(paidlogin['username'], paidlogin['secret'], 1)
    assert 'payment' in info
    paymentid = info['payment']

    info = balance(paidlogin['username'], paidlogin['secret'])
    orig_b = info['balance']

    info = pay(paidlogin['username'], paidlogin['secret'], paymentid)
    assert 'code' in info

    info = balance(paidlogin['username'], paidlogin['secret'])
    assert orig_b == info['balance']

@@ -866,99 +866,115 @@
     
-info = balance(login%5B'username'%5D, login%5B'secret'%5D)%0A    assert float(info%5B'balance'%5D) == 0.1
+assert 'result' in info%0A    assert 'id' in info%0A    assert 'error' in info%0A    assert info%5B'error'%5D is None
 %0A%0Ade

Add mining tests