Add txn 1st seen height to bid.

Format balance amount.
Start prepare script.
This commit is contained in:
tecnovert
2019-07-21 18:25:01 +02:00
parent f1efb0a317
commit 76af4a941e
12 changed files with 378 additions and 201 deletions

View File

@@ -1,11 +1,14 @@
import unittest
import tests.test_run
import tests.test_other
import tests.test_prepare
import tests.test_run
def test_suite():
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(tests.test_run)
suite.addTests(loader.loadTestsFromModule(tests.test_other))
suite.addTests(loader.loadTestsFromModule(tests.test_prepare))
suite = loader.loadTestsFromModule(tests.test_run)
return suite

51
tests/test_prepare.py Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE.txt or http://www.opensource.org/licenses/mit-license.php.
import os
import sys
import unittest
from unittest.mock import patch
from io import StringIO
import logging
import shutil
import importlib
prepareSystem = importlib.import_module('bin.basicswap-prepare')
test_path = os.path.expanduser('~/test_basicswap')
logger = logging.getLogger()
logger.level = logging.DEBUG
class Test(unittest.TestCase):
@classmethod
def tearDownClass(self):
try:
shutil.rmtree(test_path)
except Exception as e:
logger.warning('tearDownClass %s', str(e))
def test_no_overwrite(self):
testargs = ['basicswap-prepare', '-datadir=' + test_path]
with patch.object(sys, 'argv', testargs):
prepareSystem.main()
self.assertTrue(os.path.exists(os.path.join(test_path, 'basicswap.json')))
testargs = ['basicswap-prepare', '-datadir=' + test_path]
with patch('sys.stderr', new=StringIO()) as fake_stderr:
with patch.object(sys, 'argv', testargs):
with self.assertRaises(SystemExit) as cm:
prepareSystem.main()
self.assertEqual(cm.exception.code, 1)
logger.info('fake_stderr.getvalue() %s', fake_stderr.getvalue())
self.assertTrue('exists, exiting' in fake_stderr.getvalue())
if __name__ == '__main__':
unittest.main()