2016-02-21 21:25:37 +01:00
|
|
|
from src.bootstrap import node_generator
|
2016-02-27 16:52:27 +01:00
|
|
|
from src.profile import *
|
2016-03-12 11:09:58 +01:00
|
|
|
from src.tox_dns import tox_dns
|
2016-02-17 22:32:15 +01:00
|
|
|
|
|
|
|
class TestSettings():
|
2016-02-18 13:26:50 +01:00
|
|
|
|
2016-02-17 22:32:15 +01:00
|
|
|
def test_creation(self):
|
|
|
|
s = Settings()
|
|
|
|
assert s['ipv6_enabled'] is not None
|
|
|
|
assert s['notifications'] is not None
|
2016-02-18 13:26:50 +01:00
|
|
|
|
2016-02-18 17:15:38 +01:00
|
|
|
|
|
|
|
class TestProfile():
|
|
|
|
|
|
|
|
def test_search(self):
|
2016-02-25 21:40:00 +01:00
|
|
|
arr = ProfileHelper.find_profiles()
|
2016-02-18 17:15:38 +01:00
|
|
|
assert arr
|
2016-03-06 13:44:52 +01:00
|
|
|
assert len(arr) >= 2
|
2016-02-18 17:52:12 +01:00
|
|
|
|
|
|
|
def test_open(self):
|
2016-03-06 13:44:52 +01:00
|
|
|
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
|
2016-02-18 17:52:12 +01:00
|
|
|
assert data
|
|
|
|
|
|
|
|
def test_open_save(self):
|
2016-03-06 13:44:52 +01:00
|
|
|
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
|
2016-02-25 21:40:00 +01:00
|
|
|
ProfileHelper.save_profile(data)
|
2016-03-06 13:44:52 +01:00
|
|
|
new_data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
|
2016-02-18 17:52:12 +01:00
|
|
|
assert new_data == data
|
2016-02-20 09:06:24 +01:00
|
|
|
|
|
|
|
|
2016-02-21 21:25:37 +01:00
|
|
|
class TestNodeGen():
|
|
|
|
|
|
|
|
def test_generator(self):
|
|
|
|
for elem in node_generator():
|
|
|
|
assert len(elem) == 3
|
|
|
|
|
|
|
|
def test_ports(self):
|
|
|
|
for elem in node_generator():
|
|
|
|
assert elem[1] in [33445, 443, 5190, 2306, 1813]
|
2016-02-23 12:11:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestTox():
|
|
|
|
|
2016-02-24 09:33:49 +01:00
|
|
|
def test_loading(self):
|
2016-02-27 16:52:27 +01:00
|
|
|
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
|
2016-02-23 12:11:00 +01:00
|
|
|
settings = Settings.get_default_settings()
|
|
|
|
tox = tox_factory(data, settings)
|
|
|
|
for data in node_generator():
|
|
|
|
tox.bootstrap(*data)
|
|
|
|
del tox
|
2016-02-25 13:11:14 +01:00
|
|
|
|
2016-03-06 13:44:52 +01:00
|
|
|
def test_creation(self):
|
|
|
|
name = 'Toxygen User'
|
|
|
|
status_message = 'Toxing on Toxygen'
|
|
|
|
tox = tox_factory()
|
|
|
|
tox.self_set_name(name)
|
|
|
|
tox.self_set_status_message(status_message)
|
|
|
|
data = tox.get_savedata()
|
|
|
|
del tox
|
2016-03-15 20:12:37 +01:00
|
|
|
tox = tox_factory(data)
|
2016-03-06 13:44:52 +01:00
|
|
|
assert tox.self_get_name() == name
|
|
|
|
assert tox.self_get_status_message() == status_message
|
|
|
|
|
2016-02-25 13:11:14 +01:00
|
|
|
def test_friend_list(self):
|
2016-02-27 16:52:27 +01:00
|
|
|
data = ProfileHelper.open_profile(Settings.get_default_path(), 'bob')
|
2016-02-25 13:11:14 +01:00
|
|
|
settings = Settings.get_default_settings()
|
|
|
|
tox = tox_factory(data, settings)
|
|
|
|
s = tox.self_get_friend_list()
|
2016-02-25 21:40:00 +01:00
|
|
|
size = tox.self_get_friend_list_size()
|
2016-02-27 16:52:27 +01:00
|
|
|
assert size == 2
|
|
|
|
assert len(s) == 2
|
2016-02-25 13:11:14 +01:00
|
|
|
del tox
|
2016-03-12 11:09:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestDNS():
|
|
|
|
|
|
|
|
def test_dns(self):
|
|
|
|
bot_id = '56A1ADE4B65B86BCD51CC73E2CD4E542179F47959FE3E0E21B4B0ACDADE51855D34D34D37CB5'
|
|
|
|
tox_id = tox_dns('groupbot@toxme.io')
|
|
|
|
assert tox_id == bot_id
|