Move addressbook test to bitmessageqt.tests because it uses Qt
This commit is contained in:
parent
26057be6ff
commit
2f5d6214ff
|
@ -1,6 +1,7 @@
|
||||||
"""bitmessageqt tests"""
|
"""bitmessageqt tests"""
|
||||||
|
|
||||||
|
from addressbook import TestAddressbook
|
||||||
from main import TestMain, TestUISignaler
|
from main import TestMain, TestUISignaler
|
||||||
from support import TestSupport
|
from support import TestSupport
|
||||||
|
|
||||||
__all__ = ["TestMain", "TestSupport", "TestUISignaler"]
|
__all__ = ["TestAddressbook", "TestMain", "TestSupport", "TestUISignaler"]
|
||||||
|
|
17
src/bitmessageqt/tests/addressbook.py
Normal file
17
src/bitmessageqt/tests/addressbook.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import helper_addressbook
|
||||||
|
from bitmessageqt.support import createAddressIfNeeded
|
||||||
|
|
||||||
|
from main import TestBase
|
||||||
|
|
||||||
|
|
||||||
|
class TestAddressbook(TestBase):
|
||||||
|
"""Test case for addressbook"""
|
||||||
|
|
||||||
|
def test_add_own_address_to_addressbook(self):
|
||||||
|
"""Checking own address adding in addressbook"""
|
||||||
|
try:
|
||||||
|
address = createAddressIfNeeded(self.window)
|
||||||
|
self.assertFalse(
|
||||||
|
helper_addressbook.insert(label='test', address=address))
|
||||||
|
except IndexError:
|
||||||
|
self.fail("Can't generate addresses")
|
|
@ -1,35 +0,0 @@
|
||||||
"""
|
|
||||||
Create random address
|
|
||||||
"""
|
|
||||||
|
|
||||||
import time
|
|
||||||
import defaults
|
|
||||||
import queues
|
|
||||||
import state
|
|
||||||
|
|
||||||
from bmconfigparser import BMConfigParser
|
|
||||||
|
|
||||||
|
|
||||||
def checkHasNormalAddress():
|
|
||||||
"""method for checking address"""
|
|
||||||
for address in BMConfigParser().addresses():
|
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean(address, 'enabled'):
|
|
||||||
return address
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def createAddressIfNeeded(label_text, streamNumberForAddress=1):
|
|
||||||
"""method for creating random address"""
|
|
||||||
if not checkHasNormalAddress():
|
|
||||||
queues.addressGeneratorQueue.put((
|
|
||||||
'createRandomAddress', 4, streamNumberForAddress,
|
|
||||||
label_text,
|
|
||||||
1, "", False,
|
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes
|
|
||||||
))
|
|
||||||
start_time = time.time()
|
|
||||||
while int(time.time() - start_time) < 10 and state.shutdown == 0 and not checkHasNormalAddress():
|
|
||||||
time.sleep(.2)
|
|
||||||
return checkHasNormalAddress()
|
|
|
@ -343,15 +343,6 @@ class TestCore(unittest.TestCase):
|
||||||
self.assertEqual(queryreturn[0][0], 1)
|
self.assertEqual(queryreturn[0][0], 1)
|
||||||
self.delete_address_from_addressbook(self.addr)
|
self.delete_address_from_addressbook(self.addr)
|
||||||
|
|
||||||
def test_is_own_address_add_to_addressbook(self):
|
|
||||||
"""Checking own address adding in addressbook"""
|
|
||||||
from helper_addressGenerator import createAddressIfNeeded
|
|
||||||
try:
|
|
||||||
address = createAddressIfNeeded('test1')
|
|
||||||
self.assertFalse(helper_addressbook.insert(label='test', address=address))
|
|
||||||
except IndexError:
|
|
||||||
self.fail("Can't generate addresses")
|
|
||||||
|
|
||||||
def test_adding_two_same_case_sensitive_addresses(self):
|
def test_adding_two_same_case_sensitive_addresses(self):
|
||||||
"""Testing same case sensitive address store in addressbook"""
|
"""Testing same case sensitive address store in addressbook"""
|
||||||
address1 = 'BM-2cVWtdUzPwF7UNGDrZftWuHWiJ6xxBpiSP'
|
address1 = 'BM-2cVWtdUzPwF7UNGDrZftWuHWiJ6xxBpiSP'
|
||||||
|
|
Reference in New Issue
Block a user