get tests working
This commit is contained in:
@@ -1,43 +1,55 @@
|
||||
# coding: utf-8
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
import hexathon
|
||||
import pytest
|
||||
from cic_eth.server.app import create_app
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
print("Here")
|
||||
log.debug("Here")
|
||||
app = create_app({'TESTING': True})
|
||||
with app.test_client() as client:
|
||||
with app.app.test_client() as client:
|
||||
# with app.app_context():
|
||||
# init_db()
|
||||
yield client
|
||||
|
||||
|
||||
def test_account(client):
|
||||
query_string = [('password', ''),
|
||||
('register', True)]
|
||||
# Default Token
|
||||
query_string = []
|
||||
response = client.open(
|
||||
'/create_account',
|
||||
method='POST',
|
||||
'/token',
|
||||
method='GET',
|
||||
query_string=query_string)
|
||||
address_1 = response.get_json()
|
||||
print(address_1)
|
||||
default_token = response.get_json()
|
||||
|
||||
# Create Account 1
|
||||
query_string = [('password', ''),
|
||||
('register', True)]
|
||||
response = client.open(
|
||||
'/create_account',
|
||||
method='POST',
|
||||
query_string=query_string)
|
||||
address_2 = response.get_json()
|
||||
print(address_2)
|
||||
time.sleep(10)
|
||||
# Balance
|
||||
address_1 = hexathon.valid(response.get_json())
|
||||
|
||||
# Create Account 2
|
||||
query_string = [('password', ''),
|
||||
('register', True)]
|
||||
response = client.open(
|
||||
'/create_account',
|
||||
method='POST',
|
||||
query_string=query_string)
|
||||
address_2 = hexathon.valid(response.get_json())
|
||||
time.sleep(30) # Required to allow balance to show
|
||||
|
||||
# Balance Account 1
|
||||
query_string = [('address', address_1),
|
||||
('token_symbol', 'COFE'),
|
||||
('include_pending', True)]
|
||||
@@ -46,9 +58,17 @@ def test_account(client):
|
||||
method='GET',
|
||||
query_string=query_string)
|
||||
balance = response.get_json()
|
||||
print(balance)
|
||||
# Transfer
|
||||
|
||||
assert (balance[0] == {
|
||||
"address": default_token.get('address').lower(),
|
||||
"balance_available": 30000000000,
|
||||
"balance_incoming": 0,
|
||||
"balance_network": 30000000000,
|
||||
"balance_outgoing": 0,
|
||||
"converters": []
|
||||
})
|
||||
|
||||
# Transfer
|
||||
query_string = [('from_address', address_1),
|
||||
('to_address', address_2),
|
||||
('value', 100),
|
||||
@@ -58,7 +78,35 @@ def test_account(client):
|
||||
method='POST',
|
||||
query_string=query_string)
|
||||
transfer = response.get_json()
|
||||
print(transfer)
|
||||
|
||||
# Balance Account 1
|
||||
query_string = [('address', address_1),
|
||||
('token_symbol', 'COFE'),
|
||||
('include_pending', True)]
|
||||
response = client.open(
|
||||
'/balance',
|
||||
method='GET',
|
||||
query_string=query_string)
|
||||
balance_after_transfer = response.get_json()
|
||||
assert (balance_after_transfer[0] == {
|
||||
"address": default_token.get('address').lower(),
|
||||
"balance_available": 29900000000,
|
||||
"balance_incoming": 0,
|
||||
"balance_network": 30000000000,
|
||||
"balance_outgoing": 100000000,
|
||||
"converters": []
|
||||
})
|
||||
|
||||
# Transactions Account 1
|
||||
query_string = [('address', address_1),
|
||||
('limit', 10)]
|
||||
response = client.open(
|
||||
'/transactions',
|
||||
method='GET',
|
||||
query_string=query_string)
|
||||
transactions = response.get_json()
|
||||
log.debug(transactions)
|
||||
exit(1)
|
||||
|
||||
|
||||
# def test_list_transactions(client):
|
||||
|
||||
Reference in New Issue
Block a user