Add models, otx add test
This commit is contained in:
@@ -29,14 +29,6 @@ class TestBase(unittest.TestCase):
|
||||
migrationsdir = os.path.join(dbdir, 'migrations', 'default')
|
||||
logg.info('using migrations directory {}'.format(migrationsdir))
|
||||
|
||||
# db_dir = tempfile.mkdtemp()
|
||||
# self.db_path = os.path.join(db_dir, 'test.sqlite')
|
||||
# config = {
|
||||
# 'DATABASE_ENGINE': 'sqlite',
|
||||
# 'DATABASE_DRIVER': 'pysqlite',
|
||||
# 'DATABASE_NAME': self.db_path,
|
||||
# }
|
||||
|
||||
config = {
|
||||
'DATABASE_ENGINE': 'sqlite',
|
||||
'DATABASE_DRIVER': 'pysqlite',
|
||||
@@ -57,24 +49,8 @@ class TestBase(unittest.TestCase):
|
||||
alembic.command.downgrade(ac, 'base')
|
||||
alembic.command.upgrade(ac, 'head')
|
||||
|
||||
|
||||
|
||||
self.session = SessionBase.create_session()
|
||||
#
|
||||
# f = open(os.path.join(script_dir, '..', 'sql', 'sqlite', '1.sql'), 'r')
|
||||
# sql = f.read()
|
||||
# f.close()
|
||||
#
|
||||
# conn = SessionBase.engine.connect()
|
||||
# conn.execute(sql)
|
||||
#
|
||||
# f = open(os.path.join(script_dir, '..', 'sql', 'sqlite', '2.sql'), 'r')
|
||||
# sql = f.read()
|
||||
# f.close()
|
||||
#
|
||||
# conn = SessionBase.engine.connect()
|
||||
# conn.execute(sql)
|
||||
#
|
||||
|
||||
self.chain_spec = ChainSpec('evm', 'foo', 42, 'bar')
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
# standard imports
|
||||
import os
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
# external imports
|
||||
from hexathon import (
|
||||
strip_0x,
|
||||
add_0x,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from chainqueue.db.models.otx import Otx
|
||||
|
||||
# test imports
|
||||
from tests.base import TestBase
|
||||
|
||||
@@ -11,9 +21,17 @@ logg = logging.getLogger()
|
||||
class TestBasic(TestBase):
|
||||
|
||||
def test_hello(self):
|
||||
logg.debug('foo')
|
||||
pass
|
||||
|
||||
|
||||
def test_otx(self):
|
||||
tx_hash = add_0x(os.urandom(32).hex())
|
||||
address = add_0x(os.urandom(20).hex())
|
||||
tx = add_0x(os.urandom(128).hex())
|
||||
nonce = 42
|
||||
otx = Otx(nonce, tx_hash, tx)
|
||||
self.session.add(otx)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user