From 5f0e2fbd0efa165a02b17f06cde877a9f8a93183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Wieczorek?= Date: Mon, 7 Dec 2020 16:48:46 +0100 Subject: [PATCH] Refactoring. Fixes. Clean project. Add first test. --- generate_class_files_from_ui_files.sh | 4 ++-- run_tests.sh | 5 +++++ src/gui/__init__.py | 0 src/gui/images/__init__.py | 0 src/{ => gui}/images/mainwindow.png | Bin src/gui/ui/__init__.py | 0 src/{ => gui}/ui/mainwindow.ui | 6 +----- src/python/__init__.py | 0 src/python/ui/mainwindow_ui.py | 25 ++++++++++++------------- tests/__init__.py | 0 tests/gui_tests/__init__.py | 0 tests/gui_tests/test_mainwindow_ui.py | 19 +++++++++++++++++++ tests/logic_tests/__init__.py | 0 13 files changed, 39 insertions(+), 20 deletions(-) create mode 100755 run_tests.sh create mode 100644 src/gui/__init__.py create mode 100644 src/gui/images/__init__.py rename src/{ => gui}/images/mainwindow.png (100%) create mode 100644 src/gui/ui/__init__.py rename src/{ => gui}/ui/mainwindow.ui (98%) create mode 100644 src/python/__init__.py create mode 100644 tests/__init__.py create mode 100644 tests/gui_tests/__init__.py create mode 100644 tests/gui_tests/test_mainwindow_ui.py create mode 100644 tests/logic_tests/__init__.py diff --git a/generate_class_files_from_ui_files.sh b/generate_class_files_from_ui_files.sh index 119d806..f31f768 100755 --- a/generate_class_files_from_ui_files.sh +++ b/generate_class_files_from_ui_files.sh @@ -1,9 +1,9 @@ #!/bin/bash -for file in $(ls ./src/ui) +for file in $(ls ./src/gui/ui) do output_file=$(echo $file | sed -e 's/\..*$//') -pipenv run python -m PyQt5.uic.pyuic -x ./src/ui/$file -o ./src/python/ui/$output_file'_ui.py' +pipenv run python -m PyQt5.uic.pyuic -x ./src/gui/ui/$file -o ./src/python/ui/$output_file'_ui.py' done; diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..6bda3f8 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +pipenv run python -m unittest discover -s ./tests/ -p 'test_*.py' + + diff --git a/src/gui/__init__.py b/src/gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/gui/images/__init__.py b/src/gui/images/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/images/mainwindow.png b/src/gui/images/mainwindow.png similarity index 100% rename from src/images/mainwindow.png rename to src/gui/images/mainwindow.png diff --git a/src/gui/ui/__init__.py b/src/gui/ui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/mainwindow.ui b/src/gui/ui/mainwindow.ui similarity index 98% rename from src/ui/mainwindow.ui rename to src/gui/ui/mainwindow.ui index 99c0aa3..275e1c8 100644 --- a/src/ui/mainwindow.ui +++ b/src/gui/ui/mainwindow.ui @@ -20,10 +20,7 @@ 540 - - - QLayout::SetDefaultConstraint - + @@ -258,7 +255,6 @@ h_line h_line3 h_slider - verticalLayoutWidget diff --git a/src/python/__init__.py b/src/python/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/python/ui/mainwindow_ui.py b/src/python/ui/mainwindow_ui.py index 132eaa5..4479896 100644 --- a/src/python/ui/mainwindow_ui.py +++ b/src/python/ui/mainwindow_ui.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file './src/ui/mainwindow.ui' +# Form implementation generated from reading ui file './src/gui/ui/mainwindow.ui' # # Created by: PyQt5 UI code generator 5.15.2 # @@ -18,9 +18,8 @@ class Ui_MainWindow(object): self.central_widget = QtWidgets.QWidget(MainWindow) self.central_widget.setMinimumSize(QtCore.QSize(700, 540)) self.central_widget.setObjectName("central_widget") - self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.central_widget) - self.verticalLayout_2.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.vertical_layout = QtWidgets.QVBoxLayout(self.central_widget) + self.vertical_layout.setObjectName("vertical_layout") self.h_layout_select_audio1 = QtWidgets.QHBoxLayout() self.h_layout_select_audio1.setObjectName("h_layout_select_audio1") self.line_edit_audio1 = QtWidgets.QLineEdit(self.central_widget) @@ -34,7 +33,7 @@ class Ui_MainWindow(object): self.push_button_audio1 = QtWidgets.QPushButton(self.central_widget) self.push_button_audio1.setObjectName("push_button_audio1") self.h_layout_select_audio1.addWidget(self.push_button_audio1) - self.verticalLayout_2.addLayout(self.h_layout_select_audio1) + self.vertical_layout.addLayout(self.h_layout_select_audio1) self.h_layout_select_audio2 = QtWidgets.QHBoxLayout() self.h_layout_select_audio2.setObjectName("h_layout_select_audio2") self.line_edit_audio2 = QtWidgets.QLineEdit(self.central_widget) @@ -48,12 +47,12 @@ class Ui_MainWindow(object): self.push_button_audio2 = QtWidgets.QPushButton(self.central_widget) self.push_button_audio2.setObjectName("push_button_audio2") self.h_layout_select_audio2.addWidget(self.push_button_audio2) - self.verticalLayout_2.addLayout(self.h_layout_select_audio2) + self.vertical_layout.addLayout(self.h_layout_select_audio2) self.h_line3 = QtWidgets.QFrame(self.central_widget) self.h_line3.setFrameShape(QtWidgets.QFrame.HLine) self.h_line3.setFrameShadow(QtWidgets.QFrame.Sunken) self.h_line3.setObjectName("h_line3") - self.verticalLayout_2.addWidget(self.h_line3) + self.vertical_layout.addWidget(self.h_line3) self.v_layout_avatars = QtWidgets.QVBoxLayout() self.v_layout_avatars.setObjectName("v_layout_avatars") self.h_layout_avatars_preview = QtWidgets.QHBoxLayout() @@ -79,12 +78,12 @@ class Ui_MainWindow(object): self.push_button_select_avatar2.setObjectName("push_button_select_avatar2") self.h_layout_avatars_buttons.addWidget(self.push_button_select_avatar2) self.v_layout_avatars.addLayout(self.h_layout_avatars_buttons) - self.verticalLayout_2.addLayout(self.v_layout_avatars) + self.vertical_layout.addLayout(self.v_layout_avatars) self.h_line2 = QtWidgets.QFrame(self.central_widget) self.h_line2.setFrameShape(QtWidgets.QFrame.HLine) self.h_line2.setFrameShadow(QtWidgets.QFrame.Sunken) self.h_line2.setObjectName("h_line2") - self.verticalLayout_2.addWidget(self.h_line2) + self.vertical_layout.addWidget(self.h_line2) self.h_layout_threshold = QtWidgets.QHBoxLayout() self.h_layout_threshold.setObjectName("h_layout_threshold") self.label_threshold_description = QtWidgets.QLabel(self.central_widget) @@ -103,16 +102,16 @@ class Ui_MainWindow(object): self.lcd_number_of_threshold.setProperty("intValue", 0) self.lcd_number_of_threshold.setObjectName("lcd_number_of_threshold") self.h_layout_threshold.addWidget(self.lcd_number_of_threshold) - self.verticalLayout_2.addLayout(self.h_layout_threshold) + self.vertical_layout.addLayout(self.h_layout_threshold) self.h_slider = QtWidgets.QSlider(self.central_widget) self.h_slider.setOrientation(QtCore.Qt.Horizontal) self.h_slider.setObjectName("h_slider") - self.verticalLayout_2.addWidget(self.h_slider) + self.vertical_layout.addWidget(self.h_slider) self.h_line = QtWidgets.QFrame(self.central_widget) self.h_line.setFrameShape(QtWidgets.QFrame.HLine) self.h_line.setFrameShadow(QtWidgets.QFrame.Sunken) self.h_line.setObjectName("h_line") - self.verticalLayout_2.addWidget(self.h_line) + self.vertical_layout.addWidget(self.h_line) self.h_layout_preview_or_generate = QtWidgets.QHBoxLayout() self.h_layout_preview_or_generate.setObjectName("h_layout_preview_or_generate") self.push_button_preview = QtWidgets.QPushButton(self.central_widget) @@ -121,7 +120,7 @@ class Ui_MainWindow(object): self.push_button_generate = QtWidgets.QPushButton(self.central_widget) self.push_button_generate.setObjectName("push_button_generate") self.h_layout_preview_or_generate.addWidget(self.push_button_generate) - self.verticalLayout_2.addLayout(self.h_layout_preview_or_generate) + self.vertical_layout.addLayout(self.h_layout_preview_or_generate) self.h_line2.raise_() self.h_line.raise_() self.h_line3.raise_() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/gui_tests/__init__.py b/tests/gui_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/gui_tests/test_mainwindow_ui.py b/tests/gui_tests/test_mainwindow_ui.py new file mode 100644 index 0000000..987dfa6 --- /dev/null +++ b/tests/gui_tests/test_mainwindow_ui.py @@ -0,0 +1,19 @@ +from src.python.ui.mainwindow_ui import Ui_MainWindow +import unittest + + +class Test_Ui_MainWindow(unittest.TestCase): + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def test_check_create__mainwindow(self): + ui_mainwindow = Ui_MainWindow() + self.assertIsInstance(ui_mainwindow, Ui_MainWindow) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/logic_tests/__init__.py b/tests/logic_tests/__init__.py new file mode 100644 index 0000000..e69de29