tests + profile.py

This commit is contained in:
ingvar1995 2016-02-18 19:15:38 +03:00
parent 3ab7794d17
commit 14dd46b716
6 changed files with 78 additions and 22 deletions

View File

@ -4,7 +4,8 @@ from PySide import QtCore, QtGui
import sys
import os
class LoginScreen(object):
class LoginScreen(QtGui.QWidget):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 200)
@ -63,15 +64,17 @@ class LoginScreen(object):
self.groupBox_2.setTitle(QtGui.QApplication.translate("Form", "Create new profile", None, QtGui.QApplication.UnicodeUTF8))
self.toxygen.setText(QtGui.QApplication.translate("Form", "toxygen", None, QtGui.QApplication.UnicodeUTF8))
def update_select(self, data):
list_of_profiles = []
for elem in data:
list_of_profiles.append(self.tr(elem))
self.comboBox.addItems(list_of_profiles)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ls = LoginScreen()
win = QtGui.QMainWindow()
ls.setupUi(win)
win.show()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
app.exec_()

View File

@ -0,0 +1,20 @@
from loginscreen import LoginScreen
from settings import Settings
import sys
from PySide import QtCore, QtGui
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
settings = Settings()
if not settings['auto_profile']:
# show login screen if default profile not found
ls = LoginScreen()
win = QtGui.QMainWindow()
ls.setupUi(win)
ls.update_select(['tox_save'])
win.show()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
app.exec_()
# TODO: get result from loginscreen and open mainscreen

View File

@ -111,6 +111,7 @@ class MainWindow(QtGui.QWidget):
def initUI(self):
grid = QtGui.QGridLayout()
search = QtGui.QWidget()
grid.setColumnStretch(1, 1)
self.setup_left_center(search)
grid.addWidget(search, 1, 0)
name = QtGui.QWidget()

View File

@ -0,0 +1,23 @@
from settings import Settings
import os
class Profile(object):
@staticmethod
def find_profiles():
path = Settings.get_default_path()
result = []
# check default path
for fl in os.listdir(path):
if fl.endswith(".tox"):
name = fl[:-4]
result.append((path, name))
path = os.path.dirname(os.path.abspath(__file__))
# check current directory
for fl in os.listdir(path):
if fl.endswith(".tox"):
name = fl[:-4]
result.append((path, name))
return result

View File

@ -18,24 +18,25 @@ class Settings(dict):
@staticmethod
def get_default_settings():
return {
"theme": "default",
"ipv6_enabled": True,
"udp_enabled": True,
"proxy_type": 0,
"proxy_host": "0",
"proxy_port": 0,
"start_port": 0,
"end_port": 0,
"tcp_port": 0,
"notifications": True,
"sound_notifications": False,
"language": "en-en",
"save_history": False,
"allow_inline": True,
"allow_auto_accept": False,
"auto_accept_from_friends": [],
"friends_aliases": [],
"typing_notifications": True
'theme': 'default',
'ipv6_enabled': True,
'udp_enabled': True,
'proxy_type': 0,
'proxy_host': '0',
'proxy_port': 0,
'start_port': 0,
'end_port': 0,
'tcp_port': 0,
'notifications': True,
'sound_notifications': False,
'language': 'en-en',
'save_history': False,
'allow_inline': True,
'allow_auto_accept': False,
'auto_accept_from_friends': [],
'friends_aliases': [],
'typing_notifications': True,
'auto_profile': ''
}
def save(self):

View File

@ -1,6 +1,7 @@
from src.settings import Settings
from src.tox import Tox
import sys
from src.profile import Profile
import os
@ -34,3 +35,10 @@ class TestTox():
assert tox.get_savedata_size()
except:
assert 0
class TestProfile():
def test_search(self):
arr = Profile.find_profiles()
assert arr