test update

This commit is contained in:
ingvar1995 2016-03-06 15:44:52 +03:00
parent 1f0ce2d7da
commit d0a0fe6189
2 changed files with 20 additions and 13 deletions

View file

@ -5,7 +5,7 @@ import os
from tox import Tox
from toxcore_enums_and_consts import *
from ctypes import *
from util import curr_time, log
from util import curr_time, log, Singleton
class ProfileHelper(object):
@ -153,10 +153,9 @@ class Friend(Contact):
return self._number
number = property(get_number)
# TODO: check if setNumber needed
class Profile(Contact):
class Profile(Contact, Singleton):
"""
Profile of current toxygen user. Contains friends list, tox instance, list of messages
"""
@ -180,10 +179,6 @@ class Profile(Contact):
self.set_status_message(tox.self_get_status_message().encode('utf-8'))
self.filtration(self.show_online)
@staticmethod
def get_instance():
return Profile._instance
# -----------------------------------------------------------------------------------------------------------------
# Edit current user's data
# -----------------------------------------------------------------------------------------------------------------

View file

@ -1,8 +1,5 @@
from src.settings import Settings
import sys
from src.bootstrap import node_generator
from src.profile import *
import os
class TestSettings():
@ -18,15 +15,16 @@ class TestProfile():
def test_search(self):
arr = ProfileHelper.find_profiles()
assert arr
assert len(arr) >= 2
def test_open(self):
data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
assert data
def test_open_save(self):
data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
ProfileHelper.save_profile(data)
new_data = ProfileHelper.open_profile(Settings.get_default_path(), 'tox_save')
new_data = ProfileHelper.open_profile(Settings.get_default_path(), 'alice')
assert new_data == data
@ -51,6 +49,20 @@ class TestTox():
tox.bootstrap(*data)
del tox
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()
length = tox.get_savedata_size()
savedata = ''.join('{}'.format(data[i]) for i in xrange(length))
del tox
tox = tox_factory(savedata)
assert tox.self_get_name() == name
assert tox.self_get_status_message() == status_message
def test_friend_list(self):
data = ProfileHelper.open_profile(Settings.get_default_path(), 'bob')
settings = Settings.get_default_settings()