profile helper test

This commit is contained in:
ingvar1995 2016-10-28 00:55:34 +03:00
parent e5a228906d
commit 34dd74ad48
6 changed files with 23 additions and 10 deletions

View File

@ -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={

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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)