autotest on logout tbt

This commit is contained in:
neo-dl 2023-05-22 18:39:28 +02:00
parent 068cf7b973
commit 3629f86c2d
3 changed files with 20 additions and 8 deletions

View File

@ -23,7 +23,7 @@ class Archive(BaseModel):
@db.atomic() @db.atomic()
def archive(cls, test_data, result, overridden): def archive(cls, test_data, result, overridden):
time=datetime.now() time=datetime.now()
test_data["time"]=time.strftime("%Y/%m/%dT %H:%M:%S") test_data["time"]=time.strftime("%d/%m/%Y %H:%M:%S")
test_data["user"]=Users.get_session().username test_data["user"]=Users.get_session().username
return cls.create( return cls.create(
time=time, time=time,

View File

@ -68,7 +68,7 @@ try:
from lib.helpers import ConfigReader from lib.helpers import ConfigReader
from PyQt5.QtCore import QObject, QThread, pyqtSignal from PyQt5.QtCore import QObject, QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication, QMessageBox from PyQt5.QtWidgets import QApplication, QMessageBox
from ui import About, Archive, Login, Main_Window, Test, Users_Management from ui import About, Archive, Login, Main_Window, Test, Users_Management, Recipe_Selection
if "--vision" in sys.argv: if "--vision" in sys.argv:
from components import GalaxyCamera, NeoPixels, UVCCamera, Vision, VisionSaver from components import GalaxyCamera, NeoPixels, UVCCamera, Vision, VisionSaver
@ -218,17 +218,23 @@ try:
else: else:
self.main_window.admin_m.menuAction().setVisible(False) self.main_window.admin_m.menuAction().setVisible(False)
# open test # open test
self.main_window.open_tab(Test(self.config, self.components)) self.main_window.open_tab(Test(self.config, self.components,self))
else: else:
self.main_window.admin_m.menuAction().setVisible(False) self.main_window.admin_m.menuAction().setVisible(False)
def logout(self): def logout(self):
if type(self.main_window.centralWidget) is Test:
self.main_window.centralWidget.change_recipe()
self.main_window.centralWidget.request_autotest("logout")
Users.logout() Users.logout()
self.main_window.admin_m.menuAction().setVisible(False) self.main_window.admin_m.menuAction().setVisible(False)
self.open_login() if type(self.main_window.centralWidget().centralWidget.widget) is Recipe_Selection:
# LOGOUT IMMEDIATELY IF NOT TESTING
self.open_login()
else:
if not self.main_window.centralWidget().autotesting:
self.main_window.centralWidget().change_recipe() # STOP CURRENT TEST
self.main_window.centralWidget().request_autotest("logout")
else:
# LOGOUT IMMEDIATELY IF AUTOTESTING
self.open_login()
def set_recipe_mode_table(self): def set_recipe_mode_table(self):
self.main_window.centralWidget().set_recipe_mode_table() self.main_window.centralWidget().set_recipe_mode_table()

View File

@ -29,8 +29,9 @@ from ui.widget import Widget
class Test(Widget): class Test(Widget):
def __init__(self, config, components=None): def __init__(self, config, components=None,main_window=None):
super().__init__() super().__init__()
self.main_window=main_window
self.config = config self.config = config
self.components = components self.components = components
# GET LOGGER # GET LOGGER
@ -506,6 +507,11 @@ class Test(Widget):
self.pieces["ok"] += 1 self.pieces["ok"] += 1
else: else:
self.pieces["ko"] += 1 self.pieces["ko"] += 1
else:
if self.autotesting_reason == "logout":
if ok:
self.main_window.show_login()
return archived return archived
@staticmethod @staticmethod