From d0a0fe61892587ff7cec8e6b8481a6511d0e86d0 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 6 Mar 2016 15:44:52 +0300 Subject: [PATCH] test update --- src/profile.py | 9 ++------- tests/tests.py | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/profile.py b/src/profile.py index 0bdbeab..03da404 100644 --- a/src/profile.py +++ b/src/profile.py @@ -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 # ----------------------------------------------------------------------------------------------------------------- diff --git a/tests/tests.py b/tests/tests.py index a4f1540..daf5377 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -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()