m4iF4dZddlZddlmZmZmZddlmZddlZee jjZ ejjdee ddlmZddlmZmZmZmZmZGddej.Zed k(rej4yy) zTests for GUI componentsN)Mockpatch MagicMock)Path) QApplication) MainWindowJobsTab HistoryTab DashboardTab JobDialogcxeZdZdZedZdZdZdZdZ dZ e dd Z d Z d Zd Zd ZdZy)TestGUIzTest GUI componentscptj|_|jtg|_yy)z&Create QApplication once for all testsN)rinstanceapp)clss 8/mnt/ssd/data/python-lab/DaemonControl/tests/test_gui.py setUpClasszTestGUI.setUpClasss.'') 77?"2&CG ct}|j|jd|j|jj dy)zTest main window can be created DaemonControlN)r assertEqual windowTitletabscountselfwindows rtest_main_window_creationz!TestGUI.test_main_window_creations? ++-? **,a0rct}|j|j|j|jj dy)zTest jobs tab can be createdN)r assertIsNotNonetabler columnCountrtabs rtest_jobs_tab_creationzTestGUI.test_jobs_tab_creation s8i SYY' ..0!4rct}|j|j|j|jj dy)zTest history tab can be createdN)r r#r$rr%r&s rtest_history_tab_creationz!TestGUI.test_history_tab_creation's8l SYY' ..0!4rct}|j|j|j|jy)z!Test dashboard tab can be createdN)r r#active_jobs_listrecent_exec_listr&s rtest_dashboard_tab_creationz#TestGUI.test_dashboard_tab_creation.s1n S112 S112rct}|j|jd|j|jy)zTest job dialog in create modezNew JobN)r rr assertFalse is_edit_mode)rdialogs rtest_job_dialog_create_modez#TestGUI.test_job_dialog_create_mode5s6 ++-y9 ,,-rzgui.job_dialog.DatabaseManagerct}t}ddddddddd g|j_||j_t | |_t d |_||jj_td }|j|jd |j|jy )zTest job dialog in edit modezTest Jobscriptz/test/script.shz/testizTest description)idnamejob_typeexecutable_pathworking_directorytimeout descriptionN) return_valueF)job_idzEdit Job)rfetchone side_effectcursorr?r __enter____exit__get_connectionr rr assertTruer2)rmock_db mock_conn mock_cursorr3s rtest_job_dialog_edit_modez!TestGUI.test_job_dialog_edit_mode<sK k "$#4%,1   , ()4 %" : !u5 ;D++8!$ ++-z: ++,rc`t}|j|jj|j|jj|j|j j|j|j jy)z4Test jobs tab buttons are disabled without selectionN)r r1edit_btn isEnabled delete_btn toggle_btn execute_btnr&s rtest_jobs_tab_button_statesz#TestGUI.test_jobs_tab_button_statesXsui //12 1134 1134 2245rct}|j|jjdd|j|jjdd|j|jjddy)z!Test main window has correct tabsru📊 Dashboardr6u ⚙️ Jobsu 📜 HistoryN)rrrtabTextrs rtest_main_window_tabszTestGUI.test_main_window_tabsasg ,,Q/1AB ,,Q/? ,,Q/@rct}|j|j|j|jj y)z Test jobs tab has new job buttonN)r r#new_btnrGrNr&s rtest_jobs_tab_has_new_buttonz$TestGUI.test_jobs_tab_has_new_buttonis4i S[[)  --/0rct}|j|j|j|j|j|jy)z%Test history tab has filter dropdownsN)r r# job_filter status_filter period_filterr&s rtest_history_tab_filtersz TestGUI.test_history_tab_filterspsCl S^^, S../ S../rct}|j|j|j|j|j|jy)z$Test dashboard has statistics labelsN)r r#total_jobs_labelenabled_jobs_labeltotal_exec_labelr&s rtest_dashboard_has_stats_labelsz'TestGUI.test_dashboard_has_stats_labelsxsEn S112 S334 S112rN)__name__ __module__ __qualname____doc__ classmethodrr r(r+r/r4rrKrRrVrYr^rcrrrrsd'' 1553. +,---66A103rr__main__)rgunittest unittest.mockrrrpathlibrsys__file__parent project_rootpathinsertstrPyQt6.QtWidgetsrguirr r r r TestCaserrdmainrirrrys{00 H~$$++ 3|$%(HHo3ho3d zHMMOr