toxygen/tests/tests.py

59 lines
1.4 KiB
Python
Raw Normal View History

2016-02-17 22:32:15 +01:00
from src.settings import Settings
2016-02-18 13:26:50 +01:00
from src.tox import Tox
import sys
2016-02-18 17:15:38 +01:00
from src.profile import Profile
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)
class TestTox():
def test_public_key(self):
settings = Settings()
data = Profile.open_profile(Settings.get_default_path(), 'tox_save')
2016-02-18 13:26:50 +01:00
try:
tox = Tox(data, settings)
2016-02-18 20:03:21 +01:00
except:
raise
assert 0
try:
key = tox.self_get_public_key()
2016-02-18 13:26:50 +01:00
except:
2016-02-18 20:03:21 +01:00
raise
2016-02-18 13:26:50 +01:00
assert 0
2016-02-18 20:03:21 +01:00
assert len(key.raw) == 32
try:
del tox
except:
raise
2016-02-18 13:26:50 +01:00
2016-02-18 17:15:38 +01:00
class TestProfile():
def test_search(self):
arr = Profile.find_profiles()
assert arr
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