From 34dd74ad48041d19c5366ebff42dc320ffa81616 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 28 Oct 2016 00:55:34 +0300 Subject: [PATCH] profile helper test --- setup.py | 4 +--- tests/tests.py | 19 +++++++++++++++++-- toxygen/basecontact.py | 2 +- toxygen/bootstrap.py | 1 + toxygen/notifications.py | 3 +-- toxygen/settings.py | 4 ++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 4eb163e..86141f5 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ setup(name='Toxygen', version=version, description='Toxygen - Tox client', long_description='Toxygen is powerful Tox client written in Python3', - url='https://github.com/xveduk/toxygen/', + url='https://github.com/toxygen-project/toxygen/', keywords='toxygen tox messenger', author='Ingvar', maintainer='Ingvar', @@ -58,8 +58,6 @@ setup(name='Toxygen', include_package_data=True, classifiers=[ 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', ], entry_points={ diff --git a/tests/tests.py b/tests/tests.py index 36906a0..b8ac071 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,9 +1,7 @@ from toxygen.profile import * from toxygen.tox_dns import tox_dns import toxygen.toxencryptsave as encr -from toxygen.list_items import ContactItem import toxygen.messages as m -import sys import time @@ -22,6 +20,21 @@ class TestTox: assert tox.self_get_status_message() == str(status_message, 'utf-8') +class TestProfileHelper: + + def test_creation(self): + file_name, path = 'test.tox', os.path.dirname(os.path.realpath(__file__)) + '/' + data = b'test' + with open(path + file_name, 'wb') as fl: + fl.write(data) + ph = ProfileHelper(path, file_name[:4]) + assert ProfileHelper.get_path() == path + assert ph.open_profile() == data + assert os.path.exists(path + 'avatars/') + profiles = ph.find_profiles() + assert len(profiles) == 1 + + class TestDNS: def test_dns(self): @@ -97,3 +110,5 @@ class TestFriend: friend.append_message(m.TextMessage('Hello! It is test!', MESSAGE_OWNER['ME'], t, 0)) assert len(friend.get_corr()) == 2 assert len(friend.get_corr_for_saving()) == 1 + +# TODO: more friend tests and history test diff --git a/toxygen/basecontact.py b/toxygen/basecontact.py index 8988e44..cd1a0e1 100644 --- a/toxygen/basecontact.py +++ b/toxygen/basecontact.py @@ -30,7 +30,7 @@ class BaseContact: self.load_avatar() # ----------------------------------------------------------------------------------------------------------------- - # name - current name or alias of user + # Name - current name or alias of user # ----------------------------------------------------------------------------------------------------------------- def get_name(self): diff --git a/toxygen/bootstrap.py b/toxygen/bootstrap.py index 89534b7..d6473ee 100644 --- a/toxygen/bootstrap.py +++ b/toxygen/bootstrap.py @@ -2,6 +2,7 @@ import random class Node: + def __init__(self, ip, port, tox_key, rand): self._ip, self._port, self._tox_key, self.rand = ip, port, tox_key, rand diff --git a/toxygen/notifications.py b/toxygen/notifications.py index 81a8a05..20082f6 100644 --- a/toxygen/notifications.py +++ b/toxygen/notifications.py @@ -45,8 +45,7 @@ class AudioFile: format=self.p.get_format_from_width(self.wf.getsampwidth()), channels=self.wf.getnchannels(), rate=self.wf.getframerate(), - output=True - ) + output=True) def play(self): data = self.wf.readframes(self.chunk) diff --git a/toxygen/settings.py b/toxygen/settings.py index b196477..39703b4 100644 --- a/toxygen/settings.py +++ b/toxygen/settings.py @@ -202,8 +202,8 @@ class Settings(dict, Singleton): app_settings = {} if 'active_profile' not in app_settings: app_settings['active_profile'] = [] - profilepath = ProfileHelper.get_path() - app_settings['active_profile'].append(str(profilepath + str(self.name) + '.tox')) + profile_path = ProfileHelper.get_path() + app_settings['active_profile'].append(str(profile_path + str(self.name) + '.tox')) data = json.dumps(app_settings) with open(path, 'w') as fl: fl.write(data)