toxygen/tests/tests.py

69 lines
1.9 KiB
Python
Raw Normal View History

2016-02-17 21:32:15 +00:00
from src.settings import Settings
2016-02-18 12:26:50 +00:00
import sys
from src.bootstrap import node_generator
2016-02-27 15:52:27 +00:00
from src.profile import *
2016-02-18 12:26:50 +00:00
import os
2016-02-17 21:32:15 +00:00
class TestSettings():
2016-02-18 12:26:50 +00:00
2016-02-17 21:32:15 +00:00
def test_creation(self):
s = Settings()
assert s['ipv6_enabled'] is not None
assert s['notifications'] is not None
2016-02-18 12:26:50 +00:00
def test_with_delete(self):
path = Settings.get_default_path() + 'toxygen.json'
os.remove(path)
Settings()
assert os.path.exists(path)
2016-02-18 16:15:38 +00:00
class TestProfile():
def test_search(self):
2016-02-25 20:40:00 +00:00
arr = ProfileHelper.find_profiles()
2016-02-18 16:15:38 +00:00
assert arr
def test_open(self):
2016-02-25 20:40:00 +00:00
data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
assert data
def test_open_save(self):
2016-02-25 20:40:00 +00:00
data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
ProfileHelper.save_profile(data)
new_data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
assert new_data == data
2016-02-20 08:06:24 +00: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 11:11:00 +00:00
class TestTox():
def test_loading(self):
2016-02-27 15:52:27 +00:00
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
2016-02-23 11:11:00 +00:00
settings = Settings.get_default_settings()
tox = tox_factory(data, settings)
for data in node_generator():
tox.bootstrap(*data)
del tox
2016-02-25 12:11:14 +00:00
def test_friend_list(self):
2016-02-27 15:52:27 +00:00
data = ProfileHelper.open_profile(Settings.get_default_path(), 'bob')
2016-02-25 12:11:14 +00:00
settings = Settings.get_default_settings()
tox = tox_factory(data, settings)
s = tox.self_get_friend_list()
2016-02-25 20:40:00 +00:00
size = tox.self_get_friend_list_size()
2016-02-27 15:52:27 +00:00
assert size == 2
assert len(s) == 2
2016-02-25 12:11:14 +00:00
del tox