zbxcat/xcat/tests/test_cli.py

64 lines
1.7 KiB
Python
Raw Normal View History

2017-07-28 20:45:46 -07:00
import unittest
import xcat.cli as cli
2017-09-12 22:28:36 -07:00
from xcat.db import DB
from xcat.protocol import Protocol
2017-09-15 10:12:13 -07:00
import xcat.tests.utils as testutils
from xcat.trades import Trade # , Contract
2017-07-28 20:45:46 -07:00
2017-09-04 10:00:59 -07:00
class SimpleTestCase(unittest.TestCase):
def setUp(self):
2017-09-15 10:12:13 -07:00
self.trade = testutils.mktrade()
2017-07-28 20:45:46 -07:00
def test_exporttrade(self):
self.__class__.hexstr = cli.exporttrade('test')
self.assertTrue(int(self.hexstr, 16))
2017-07-28 20:45:46 -07:00
2017-07-31 17:06:58 -07:00
def test_importtrade(self):
# trade = cli.importtrade('test', self.__class__.hexstr)
pass
2017-09-04 09:06:30 -07:00
class CliTest(SimpleTestCase):
2017-09-15 10:12:13 -07:00
2017-07-31 19:13:46 -07:00
def test_findtrade(self):
# trade = cli.findtrade('test')
pass
2017-07-31 13:32:51 -07:00
2017-07-31 19:13:46 -07:00
def test_newtrade(self):
trade = cli.newtrade('new', conf='regtest')
self.assertTrue(isinstance(trade, Trade))
2017-08-06 23:19:21 -07:00
def test_fundsell(self):
2017-09-12 22:28:36 -07:00
db = DB()
protocol = Protocol()
trade = db.get('new')
2017-09-15 10:12:13 -07:00
status = cli.seller_check_status(trade)
print("Trade status: {0}\n".format(status))
self.assertEqual(status, 'init')
fund_tx = protocol.fund_sell_contract(trade)
print("Sent fund_tx", fund_tx)
# def test_fundbuy(self):
# trade = db.get('new')
# status = cli.buyer_check_status(trade)
# self.assertEqual(status, 'sellerFunded')
# fund_tx = cli.fund_contract(trade.buy)
#
# def test_seller_redeem(self):
# trade = db.get('new')
# status = cli.seller_check_status(trade)
# self.assertEqual(status, 'buyerFunded')
#
# def test_buyer_redeem(self):
# trade = db.get('new')
# status = cli.buyer_check_status(trade)
# self.assertEqual(status, 'sellerFunded')
2017-09-04 10:00:59 -07:00
2017-09-12 22:28:36 -07:00
2017-07-28 20:45:46 -07:00
if __name__ == '__main__':
unittest.main()