Rewrite TestAPIThread as subclass of TestPartialRun
This commit is contained in:
parent
2c2a41d105
commit
1b7a642d6a
|
@ -1,25 +1,22 @@
|
||||||
|
"""TestAPIThread class definition"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import unittest
|
|
||||||
|
|
||||||
from six.moves import queue, xmlrpc_client
|
from six.moves import queue, xmlrpc_client
|
||||||
|
|
||||||
from pybitmessage import pathmagic
|
from .partial import TestPartialRun
|
||||||
|
|
||||||
from .samples import sample_statusbar_msg # any
|
from .samples import sample_statusbar_msg # any
|
||||||
|
|
||||||
|
|
||||||
class TestAPIThread(unittest.TestCase):
|
class TestAPIThread(TestPartialRun):
|
||||||
"""Test case running the API thread"""
|
"""Test case running the API thread"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
pathmagic.setup() # need this because of import state in network ):
|
super(TestAPIThread, cls).setUpClass()
|
||||||
|
|
||||||
import helper_sql
|
import helper_sql
|
||||||
import helper_startup
|
|
||||||
import queues
|
import queues
|
||||||
import state
|
|
||||||
from bmconfigparser import BMConfigParser
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class SqlReadyMock(object):
|
class SqlReadyMock(object):
|
||||||
|
@ -30,16 +27,11 @@ class TestAPIThread(unittest.TestCase):
|
||||||
return
|
return
|
||||||
|
|
||||||
helper_sql.sql_ready = SqlReadyMock
|
helper_sql.sql_ready = SqlReadyMock
|
||||||
cls.state = state
|
|
||||||
cls.queues = queues
|
cls.queues = queues
|
||||||
|
|
||||||
helper_startup.loadConfig()
|
cls.config.set('bitmessagesettings', 'apiusername', 'username')
|
||||||
# helper_startup.fixSocket()
|
cls.config.set('bitmessagesettings', 'apipassword', 'password')
|
||||||
config = BMConfigParser()
|
cls.config.set('inventory', 'storage', 'filesystem')
|
||||||
|
|
||||||
config.set('bitmessagesettings', 'apiusername', 'username')
|
|
||||||
config.set('bitmessagesettings', 'apipassword', 'password')
|
|
||||||
config.set('inventory', 'storage', 'filesystem')
|
|
||||||
|
|
||||||
import api
|
import api
|
||||||
cls.thread = api.singleAPI()
|
cls.thread = api.singleAPI()
|
||||||
|
@ -66,7 +58,3 @@ class TestAPIThread(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(cmd, 'updateStatusBar')
|
self.assertEqual(cmd, 'updateStatusBar')
|
||||||
self.assertEqual(data, sample_statusbar_msg)
|
self.assertEqual(data, sample_statusbar_msg)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
cls.state.shutdown = 1
|
|
||||||
|
|
Reference in New Issue
Block a user