tests update
This commit is contained in:
parent
67e9c92c09
commit
821dce5f28
@ -28,4 +28,6 @@ before_script:
|
|||||||
- echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf
|
- echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf
|
||||||
- sudo ldconfig
|
- sudo ldconfig
|
||||||
- cd ..
|
- cd ..
|
||||||
script: py.test tests/travis.py
|
script:
|
||||||
|
- py.test tests/travis.py
|
||||||
|
- py.test tests/tests.py
|
||||||
|
@ -1,31 +1,14 @@
|
|||||||
from toxygen.bootstrap import node_generator
|
|
||||||
from toxygen.profile import *
|
from toxygen.profile import *
|
||||||
from toxygen.settings import ProfileHelper
|
|
||||||
from toxygen.tox_dns import tox_dns
|
from toxygen.tox_dns import tox_dns
|
||||||
import toxygen.toxencryptsave as encr
|
import toxygen.toxencryptsave as encr
|
||||||
|
from toxygen.list_items import ContactItem
|
||||||
|
import toxygen.messages as m
|
||||||
class TestProfile:
|
import sys
|
||||||
|
import time
|
||||||
def test_search(self):
|
|
||||||
arr = ProfileHelper.find_profiles()
|
|
||||||
assert len(arr) >= 2
|
|
||||||
|
|
||||||
def test_open(self):
|
|
||||||
data = ProfileHelper(Settings.get_default_path(), 'alice').open_profile()
|
|
||||||
assert data
|
|
||||||
|
|
||||||
|
|
||||||
class TestTox:
|
class TestTox:
|
||||||
|
|
||||||
def test_loading(self):
|
|
||||||
data = ProfileHelper(Settings.get_default_path(), 'alice').open_profile()
|
|
||||||
settings = Settings.get_default_settings()
|
|
||||||
tox = tox_factory(data, settings)
|
|
||||||
for data in node_generator():
|
|
||||||
tox.bootstrap(*data)
|
|
||||||
del tox
|
|
||||||
|
|
||||||
def test_creation(self):
|
def test_creation(self):
|
||||||
name = b'Toxygen User'
|
name = b'Toxygen User'
|
||||||
status_message = b'Toxing on Toxygen'
|
status_message = b'Toxing on Toxygen'
|
||||||
@ -38,33 +21,81 @@ class TestTox:
|
|||||||
assert tox.self_get_name() == str(name, 'utf-8')
|
assert tox.self_get_name() == str(name, 'utf-8')
|
||||||
assert tox.self_get_status_message() == str(status_message, 'utf-8')
|
assert tox.self_get_status_message() == str(status_message, 'utf-8')
|
||||||
|
|
||||||
def test_friend_list(self):
|
|
||||||
data = ProfileHelper(Settings.get_default_path(), 'bob').open_profile()
|
|
||||||
settings = Settings.get_default_settings()
|
|
||||||
tox = tox_factory(data, settings)
|
|
||||||
s = tox.self_get_friend_list()
|
|
||||||
size = tox.self_get_friend_list_size()
|
|
||||||
assert size <= 2
|
|
||||||
assert len(s) <= 2
|
|
||||||
del tox
|
|
||||||
|
|
||||||
|
|
||||||
class TestDNS:
|
class TestDNS:
|
||||||
|
|
||||||
def test_dns(self):
|
def test_dns(self):
|
||||||
|
Settings._instance = Settings.get_default_settings()
|
||||||
bot_id = '56A1ADE4B65B86BCD51CC73E2CD4E542179F47959FE3E0E21B4B0ACDADE51855D34D34D37CB5'
|
bot_id = '56A1ADE4B65B86BCD51CC73E2CD4E542179F47959FE3E0E21B4B0ACDADE51855D34D34D37CB5'
|
||||||
tox_id = tox_dns('groupbot@toxme.io')
|
tox_id = tox_dns('groupbot@toxme.io')
|
||||||
assert tox_id == bot_id
|
assert tox_id == bot_id
|
||||||
|
|
||||||
|
def test_dns2(self):
|
||||||
|
Settings._instance = Settings.get_default_settings()
|
||||||
|
bot_id = '76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6'
|
||||||
|
tox_id = tox_dns('echobot@toxme.io')
|
||||||
|
assert tox_id == bot_id
|
||||||
|
|
||||||
|
|
||||||
class TestEncryption:
|
class TestEncryption:
|
||||||
|
|
||||||
def test_encr_decr(self):
|
def test_encr_decr(self):
|
||||||
with open(settings.Settings.get_default_path() + '/alice.tox', 'rb') as fl:
|
tox = tox_factory()
|
||||||
data = fl.read()
|
data = tox.get_savedata()
|
||||||
lib = encr.ToxEncryptSave()
|
lib = encr.ToxEncryptSave()
|
||||||
lib.set_password('easypassword')
|
lib.set_password('easypassword')
|
||||||
copy_data = data[:]
|
copy_data = data[:]
|
||||||
data = lib.pass_encrypt(data)
|
data = lib.pass_encrypt(data)
|
||||||
data = lib.pass_decrypt(data)
|
data = lib.pass_decrypt(data)
|
||||||
assert copy_data == data
|
assert copy_data == data
|
||||||
|
|
||||||
|
|
||||||
|
class TestFriend:
|
||||||
|
|
||||||
|
def create_singletons(self):
|
||||||
|
Settings._instance = Settings.get_default_settings()
|
||||||
|
ProfileHelper('', 'test')
|
||||||
|
|
||||||
|
def create_friend(self, name, status_message, number, tox_id):
|
||||||
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
message_getter = None
|
||||||
|
friend = Friend(message_getter, number, name, status_message, ContactItem(), tox_id)
|
||||||
|
return friend
|
||||||
|
|
||||||
|
def test_friend_creation(self):
|
||||||
|
self.create_singletons()
|
||||||
|
name, status_message, number = 'Friend', 'I am friend!', 0
|
||||||
|
tox_id = '76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6'
|
||||||
|
friend = self.create_friend(name, status_message, number, tox_id)
|
||||||
|
assert friend.name == name
|
||||||
|
assert friend.tox_id == tox_id
|
||||||
|
assert friend.status_message == status_message
|
||||||
|
assert friend.number == number
|
||||||
|
|
||||||
|
def test_friend_corr(self):
|
||||||
|
self.create_singletons()
|
||||||
|
name, status_message, number = 'Friend', 'I am friend!', 0
|
||||||
|
tox_id = '76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6'
|
||||||
|
friend = self.create_friend(name, status_message, number, tox_id)
|
||||||
|
t = time.time()
|
||||||
|
friend.append_message(m.InfoMessage('Info message', t))
|
||||||
|
friend.append_message(m.TextMessage('Hello! It is test!', MESSAGE_OWNER['ME'], t + 0.001, 0))
|
||||||
|
friend.append_message(m.TextMessage('Hello!', MESSAGE_OWNER['FRIEND'], t + 0.002, 0))
|
||||||
|
assert friend.get_last_message_text() == 'Hello! It is test!'
|
||||||
|
assert len(friend.get_corr()) == 3
|
||||||
|
assert len(friend.get_corr_for_saving()) == 2
|
||||||
|
friend.append_message(m.TextMessage('Not sent', MESSAGE_OWNER['NOT_SENT'], t + 0.002, 0))
|
||||||
|
arr = friend.get_unsent_messages_for_saving()
|
||||||
|
assert len(arr) == 1
|
||||||
|
assert arr[0][0] == 'Not sent'
|
||||||
|
tm = m.TransferMessage(MESSAGE_OWNER['FRIEND'],
|
||||||
|
time.time(),
|
||||||
|
TOX_FILE_TRANSFER_STATE['RUNNING'],
|
||||||
|
100, 'file_name', friend.number, 0)
|
||||||
|
friend.append_message(tm)
|
||||||
|
friend.clear_corr()
|
||||||
|
assert len(friend.get_corr()) == 1
|
||||||
|
assert len(friend.get_corr_for_saving()) == 0
|
||||||
|
friend.append_message(m.TextMessage('Hello! It is test!', MESSAGE_OWNER['ME'], t, 0))
|
||||||
|
assert len(friend.get_corr()) == 2
|
||||||
|
assert len(friend.get_corr_for_saving()) == 1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class TestToxygen:
|
class TestToxygen:
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
import toxygen.main
|
import toxygen.main # check for syntax errors
|
||||||
|
Loading…
Reference in New Issue
Block a user