Basic structure of unit tests

pull/1/head
slush 12 years ago
parent 05a15eaf7d
commit b6106fa681

@ -0,0 +1,10 @@
import sys
sys.path = ['../',] + sys.path
from bitkeylib.transport_pipe import PipeTransport
TRANSPORT = PipeTransport
TRANSPORT_ARGS = ('../../bitkey-python/device.socket', False)
DEBUG_TRANSPORT = PipeTransport
DEBUG_TRANSPORT_ARGS = ('../../bitkey-python/device.socket.debug', False)

@ -0,0 +1,3 @@
#!/bin/bash
python -m unittest discover

@ -1,20 +1,37 @@
#!/usr/bin/python
'''
import sys
sys.path = ['../',] + sys.path
import time
ENABLE_DEBUG_LINK = True
from bitkeylib.transport_pipe import PipeTransport
from bitkeylib.transport_serial import SerialTransport
import bitkeylib.bitkey_pb2 as proto
from bitkeylib.transport_fake import FakeTransport
from bitkeylib import proto
from bitkeylib.client import BitkeyClient
from bitkeylib.debuglink import DebugLink
transport = PipeTransport('../../bitkey-python/device.socket', is_device=False)
if ENABLE_DEBUG_LINK:
debug_transport = PipeTransport('../../bitkey-python/device.socket.debug', is_device=False)
debuglink = DebugLink(debug_transport)
else:
debuglink = None
bitkey = BitkeyClient('../../bitkey-python/device.socket', debug=True)
bitkey.open()
bitkey.call(proto.Ping(message='ahoj!'))
bitkey.call(proto.SetMaxFeeKb(maxfee_kb=200000))
bitkey.close()
bitkey = BitkeyClient(transport, debuglink)
print bitkey.call(proto.Initialize())
#bitkey.call(proto.Ping(message='ahoj!'))
#bitkey.call(proto.GetUUID())
print bitkey.call(proto.GetEntropy(size=10), button=True)
bitkey.call(proto.SetMaxFeeKb(maxfee_kb=100000), button=True, pin_correct=False)
'''
'''
d = PipeTransport('../bitkey-python/device.socket', is_device=False)

@ -0,0 +1,19 @@
import unittest
import config
from bitkeylib.client import BitkeyClient
from bitkeylib import proto
class TestBasic(unittest.TestCase):
def setUp(self):
self.debuglink = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS)
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
self.bitkey = BitkeyClient(self.transport, self.debuglink)
def tearDown(self):
self.debuglink.close()
self.transport.close()
def test_basic(self):
self.assertEqual(self.bitkey.call(proto.Ping(message='ahoj!')), proto.Success(message='ahoj!'))
Loading…
Cancel
Save