From 8dae4fcad90f584585d2019a96eb1f48885409e8 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 21 Feb 2016 23:25:37 +0300 Subject: [PATCH] tests update, added program version string --- src/mainscreen.py | 8 ++++++++ src/util.py | 7 +++++-- tests/tests.py | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mainscreen.py b/src/mainscreen.py index d014a04..5ec6bac 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -44,6 +44,7 @@ class MainWindow(QtGui.QMainWindow): self.menuSettings.addAction(self.actionNotifications) self.menuSettings.addAction(self.actionNetwork) self.menuAbout.addAction(self.actionAbout_program) + self.actionAbout_program.triggered.connect(self.about_program) self.menubar.addAction(self.menuProfile.menuAction()) self.menubar.addAction(self.menuSettings.menuAction()) self.menubar.addAction(self.menuAbout.menuAction()) @@ -61,6 +62,13 @@ class MainWindow(QtGui.QMainWindow): self.actionSettings.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8)) QtCore.QMetaObject.connectSlotsByName(MainWindow) + def about_program(self): + import util + msgBox = QtGui.QMessageBox() + msgBox.setWindowTitle("About") + msgBox.setText("Toxygen is pythonic Tox client. Version: " + util.program_version) + msgBox.exec_() + def setup_right_bottom(self, Form): Form.setObjectName("right_bottom") Form.resize(500, 150) diff --git a/src/util.py b/src/util.py index a7ff2e8..8b5928c 100644 --- a/src/util.py +++ b/src/util.py @@ -1,12 +1,15 @@ +program_version = '0.0.1 (alpha)' + + def log(data): - with open("logs.log", "a") as fl: + with open('logs.log', 'a') as fl: fl.write(str(data)) def string_to_bin(tox_id): - return tox_id.decode("hex") + return tox_id.decode('hex') def bin_to_string(raw_id): diff --git a/tests/tests.py b/tests/tests.py index 806527c..1e44e1e 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,7 +1,7 @@ from src.settings import Settings -from src.tox import Tox from src.util import bin_to_string, string_to_bin import sys +from src.bootstrap import node_generator from src.profile import Profile import os @@ -18,7 +18,7 @@ class TestSettings(): os.remove(path) Settings() assert os.path.exists(path) - + class TestProfile(): @@ -44,3 +44,14 @@ class TestUtils(): data = string_to_bin(id) new_id = bin_to_string(data) assert id == new_id + + +class TestNodeGen(): + + def test_generator(self): + for elem in node_generator(): + assert len(elem) == 3 + + def test_ports(self): + for elem in node_generator(): + assert elem[1] in [33445, 443, 5190, 2306, 1813]