Skip to content

Commit

Permalink
Merge pull request #18 from newcleo-dev-team/012_test_framework
Browse files Browse the repository at this point in the history
Created the test framework
  • Loading branch information
dmanzione authored Jul 13, 2024
2 parents ed3486f + 3ad502c commit b64860c
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Test all scripts in tests/ and doc compilation
name: main_actions

on: push

jobs:
test_all_tests:
runs-on: [ubuntu-latest]
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install python3-tk
- run: pip install ttkthemes
- run: pip install pandas
- run: pip install matplotlib
- run: python3 -m unittest tests/test_gui_window_basic.py -v

test_documentation:
if: contains( github.ref, 'master')
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install python3-sphinx
- run: pip install sphinx-rtd-theme
- run: pip install myst-parser
- run: pip install sphinxcontrib-bibtex
- run: make html
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ build/
**/__pycache__
# Docs files and directories
docs/_build
# Exe files
resources/exec
# IDE files and directories
*.code-workspace
.idea/
Expand Down
17 changes: 17 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Testing module for ``tugui``
"""
import os
import sys


PROJECT_PATH = os.getcwd()
SOURCE_PATH = os.path.join(
PROJECT_PATH,"tugui"
)
sys.path.append(SOURCE_PATH)

RESOURCES_PATH = os.path.join(
SOURCE_PATH, 'resources'
)
sys.path.append(RESOURCES_PATH)
27 changes: 27 additions & 0 deletions tests/test_gui_window_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import sys
from tkinter import TclError
import unittest

from tugui.main import TuPostProcessingGui

class TestGUI(unittest.TestCase):
"""
"""

def test_01_gui_building_no_exec(self):
"""
"""
print("#-------------------------------------")
print("'TuPostProcessingGui' tests started:")
print("Checking initial setup...")
# Instantiate the GUI class
try:
print(" -> test_gui_building_no_exec: ", end="")
self.root = TuPostProcessingGui("GUI Window", 300, 150)
except Exception as e:
print("successful")


if __name__ == '__main__':
unittest.main(verbosity=2)
6 changes: 4 additions & 2 deletions tugui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from gui_widgets import CustomNotebook, LabelImage
from shutil import copyfile

ERROR_LEVEL: bool = 0

class BaseWindow(ThemedTk):
"""
Base window without anything. It allows to set the window title, as well as
Expand Down Expand Up @@ -167,8 +169,8 @@ def __init__(self, window_title, height, width):
try:
self.guiconfig = GuiPlotFieldsConfigurator()
except Exception as e:
# Intercept any exception produced by running the configuration logic
messagebox.showerror("Error", type(e).__name__ + "–" + str(e))
# Intercept any exception produced by running the configuration logic according to the selected error level
if ERROR_LEVEL: messagebox.showerror("Error", type(e).__name__ + "–" + str(e))
# Quit the application as this case represents a fatal error
self.quit_app()
# Propagate the caught exception
Expand Down

0 comments on commit b64860c

Please sign in to comment.