2016-02-17 22:32:15 +01:00
|
|
|
from src.settings import Settings
|
2016-02-20 09:06:24 +01:00
|
|
|
from src.util import bin_to_string, string_to_bin
|
2016-02-18 13:26:50 +01:00
|
|
|
import sys
|
2016-02-21 21:25:37 +01:00
|
|
|
from src.bootstrap import node_generator
|
2016-02-23 12:11:00 +01:00
|
|
|
from src.profile import Profile, tox_factory
|
2016-02-18 13:26:50 +01:00
|
|
|
import os
|
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
|
|
|
|
|
|
|
def test_with_delete(self):
|
|
|
|
path = Settings.get_default_path() + 'toxygen.json'
|
|
|
|
os.remove(path)
|
|
|
|
Settings()
|
|
|
|
assert os.path.exists(path)
|
2016-02-21 21:25:37 +01:00
|
|
|
|
2016-02-18 17:15:38 +01:00
|
|
|
|
|
|
|
class TestProfile():
|
|
|
|
|
|
|
|
def test_search(self):
|
|
|
|
arr = Profile.find_profiles()
|
|
|
|
assert arr
|
2016-02-18 17:52:12 +01:00
|
|
|
|
|
|
|
def test_open(self):
|
|
|
|
data = Profile.open_profile(Settings.get_default_path(), 'tox_save')
|
|
|
|
assert data
|
|
|
|
|
|
|
|
def test_open_save(self):
|
|
|
|
data = Profile.open_profile(Settings.get_default_path(), 'tox_save')
|
|
|
|
Profile.save_profile(data)
|
|
|
|
new_data = Profile.open_profile(Settings.get_default_path(), 'tox_save')
|
|
|
|
assert new_data == data
|
2016-02-20 09:06:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestUtils():
|
|
|
|
|
|
|
|
def test_convert(self):
|
|
|
|
id = 'C4CEB8C7AC607C6B374E2E782B3C00EA3A63B80D4910B8649CCACDD19F260819'
|
|
|
|
data = string_to_bin(id)
|
|
|
|
new_id = bin_to_string(data)
|
|
|
|
assert id == new_id
|
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():
|
|
|
|
|
|
|
|
def test_creation(self):
|
|
|
|
data = Profile.open_profile(Settings.get_default_path(), 'tox_save')
|
|
|
|
settings = Settings.get_default_settings()
|
|
|
|
tox = tox_factory(data, settings)
|
|
|
|
for data in node_generator():
|
|
|
|
tox.bootstrap(*data)
|
|
|
|
del tox
|