OpenOrchestrator 1.3.1__py3-none-any.whl → 2.0.0rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- OpenOrchestrator/__main__.py +66 -12
- OpenOrchestrator/common/connection_frame.py +10 -4
- OpenOrchestrator/database/base.py +8 -0
- OpenOrchestrator/database/constants.py +3 -15
- OpenOrchestrator/database/db_util.py +110 -37
- OpenOrchestrator/database/logs.py +3 -15
- OpenOrchestrator/database/queues.py +3 -15
- OpenOrchestrator/database/schedulers.py +32 -0
- OpenOrchestrator/database/triggers.py +7 -16
- OpenOrchestrator/orchestrator/application.py +13 -8
- OpenOrchestrator/orchestrator/datetime_input.py +2 -2
- OpenOrchestrator/orchestrator/popups/constant_popup.py +8 -6
- OpenOrchestrator/orchestrator/popups/credential_popup.py +10 -8
- OpenOrchestrator/orchestrator/popups/generic_popups.py +15 -2
- OpenOrchestrator/orchestrator/popups/trigger_popup.py +25 -14
- OpenOrchestrator/orchestrator/tabs/constants_tab.py +5 -2
- OpenOrchestrator/orchestrator/tabs/logging_tab.py +3 -0
- OpenOrchestrator/orchestrator/tabs/queue_tab.py +4 -1
- OpenOrchestrator/orchestrator/tabs/schedulers_tab.py +45 -0
- OpenOrchestrator/orchestrator/tabs/settings_tab.py +2 -5
- OpenOrchestrator/orchestrator/tabs/trigger_tab.py +9 -5
- OpenOrchestrator/orchestrator/test_helper.py +17 -0
- OpenOrchestrator/orchestrator_connection/connection.py +21 -4
- OpenOrchestrator/scheduler/application.py +3 -2
- OpenOrchestrator/scheduler/run_tab.py +16 -6
- OpenOrchestrator/scheduler/runner.py +52 -64
- OpenOrchestrator/scheduler/settings_tab.py +90 -14
- OpenOrchestrator/scheduler/util.py +8 -0
- OpenOrchestrator/tests/__init__.py +0 -0
- OpenOrchestrator/tests/db_test_util.py +40 -0
- OpenOrchestrator/tests/test_db_util.py +372 -0
- OpenOrchestrator/tests/test_orchestrator_connection.py +142 -0
- OpenOrchestrator/tests/test_trigger_polling.py +143 -0
- OpenOrchestrator/tests/ui_tests/__init__.py +0 -0
- OpenOrchestrator/tests/ui_tests/test_constants_tab.py +167 -0
- OpenOrchestrator/tests/ui_tests/test_logging_tab.py +180 -0
- OpenOrchestrator/tests/ui_tests/test_queues_tab.py +126 -0
- OpenOrchestrator/tests/ui_tests/test_schedulers_tab.py +47 -0
- OpenOrchestrator/tests/ui_tests/test_trigger_tab.py +243 -0
- OpenOrchestrator/tests/ui_tests/ui_util.py +151 -0
- openorchestrator-2.0.0rc2.dist-info/METADATA +158 -0
- openorchestrator-2.0.0rc2.dist-info/RECORD +55 -0
- {openorchestrator-1.3.1.dist-info → openorchestrator-2.0.0rc2.dist-info}/WHEEL +1 -1
- OpenOrchestrator/scheduler/connection_frame.py +0 -96
- openorchestrator-1.3.1.dist-info/METADATA +0 -60
- openorchestrator-1.3.1.dist-info/RECORD +0 -39
- {openorchestrator-1.3.1.dist-info → openorchestrator-2.0.0rc2.dist-info/licenses}/LICENSE +0 -0
- {openorchestrator-1.3.1.dist-info → openorchestrator-2.0.0rc2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
"""Tests relating to the constants tab in Orchestrator."""
|
2
|
+
|
3
|
+
import unittest
|
4
|
+
import time
|
5
|
+
|
6
|
+
from selenium.webdriver.common.by import By
|
7
|
+
|
8
|
+
from OpenOrchestrator.tests import db_test_util
|
9
|
+
from OpenOrchestrator.database import db_util
|
10
|
+
from OpenOrchestrator.common import crypto_util
|
11
|
+
from OpenOrchestrator.tests.ui_tests import ui_util
|
12
|
+
|
13
|
+
|
14
|
+
class TestConstantsTab(unittest.TestCase):
|
15
|
+
"""Test functionality of the constants tab ui."""
|
16
|
+
def setUp(self) -> None:
|
17
|
+
self.browser = ui_util.open_orchestrator()
|
18
|
+
db_test_util.establish_clean_database()
|
19
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constants_tab]").click()
|
20
|
+
ui_util.refresh_ui(self.browser)
|
21
|
+
|
22
|
+
def tearDown(self) -> None:
|
23
|
+
self.browser.quit()
|
24
|
+
|
25
|
+
@ui_util.screenshot_on_error
|
26
|
+
def test_constants_table(self):
|
27
|
+
"""Test that constants are shown correctly in the constants table."""
|
28
|
+
db_util.create_constant("Constant 1", "Value 1")
|
29
|
+
db_util.create_constant("Constant 2", "Value 2")
|
30
|
+
ui_util.refresh_ui(self.browser)
|
31
|
+
|
32
|
+
table_data = ui_util.get_table_data(self.browser, "constants_tab_constants_table")
|
33
|
+
|
34
|
+
self.assertEqual(table_data[0][0], "Constant 1")
|
35
|
+
self.assertEqual(table_data[0][1], "Value 1")
|
36
|
+
self.assertRegex(table_data[0][2], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
37
|
+
|
38
|
+
self.assertEqual(table_data[1][0], "Constant 2")
|
39
|
+
self.assertEqual(table_data[1][1], "Value 2")
|
40
|
+
self.assertRegex(table_data[1][2], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
41
|
+
|
42
|
+
@ui_util.screenshot_on_error
|
43
|
+
def test_credentials_table(self):
|
44
|
+
"""Test that credentials are shown correctly in the credentials table."""
|
45
|
+
db_util.create_credential("Credential 1", "Username 1", "abc")
|
46
|
+
db_util.create_credential("Credential 2", "Username 2", "abcdefghijklmnopq")
|
47
|
+
ui_util.refresh_ui(self.browser)
|
48
|
+
|
49
|
+
table_data = ui_util.get_table_data(self.browser, "constants_tab_credentials_table")
|
50
|
+
|
51
|
+
self.assertEqual(table_data[0][0], "Credential 1")
|
52
|
+
self.assertEqual(table_data[0][1], "Username 1")
|
53
|
+
self.assertEqual(table_data[0][2], "100 encrypted bytes. 0-15 decrypted bytes.")
|
54
|
+
self.assertRegex(table_data[0][3], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
55
|
+
|
56
|
+
self.assertEqual(table_data[1][0], "Credential 2")
|
57
|
+
self.assertEqual(table_data[1][1], "Username 2")
|
58
|
+
self.assertEqual(table_data[1][2], "120 encrypted bytes. 16-31 decrypted bytes.")
|
59
|
+
self.assertRegex(table_data[1][3], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
60
|
+
|
61
|
+
@ui_util.screenshot_on_error
|
62
|
+
def test_create_constant(self):
|
63
|
+
"""Test creating a constant."""
|
64
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constants_tab_constant_button]").click()
|
65
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_name_input]").send_keys("Constant Name")
|
66
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_value_input]").send_keys("Constant Value")
|
67
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_save_button]").click()
|
68
|
+
time.sleep(1)
|
69
|
+
|
70
|
+
constant = db_util.get_constant("Constant Name")
|
71
|
+
self.assertEqual(constant.name, "Constant Name")
|
72
|
+
self.assertEqual(constant.value, "Constant Value")
|
73
|
+
|
74
|
+
@ui_util.screenshot_on_error
|
75
|
+
def test_create_credential(self):
|
76
|
+
"""Test creating a credential."""
|
77
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constants_tab_credential_button]").click()
|
78
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_name_input]").send_keys("Credential Name")
|
79
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_username_input]").send_keys("Credential Username")
|
80
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_password_input]").send_keys("Credential Password")
|
81
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_save_button]").click()
|
82
|
+
time.sleep(1)
|
83
|
+
|
84
|
+
# Make sure the encryption key matches the one in the ui
|
85
|
+
crypto_util.set_key(ui_util.ENCRYPTION_KEY)
|
86
|
+
|
87
|
+
credential = db_util.get_credential("Credential Name")
|
88
|
+
self.assertEqual(credential.name, "Credential Name")
|
89
|
+
self.assertEqual(credential.username, "Credential Username")
|
90
|
+
self.assertEqual(credential.password, "Credential Password")
|
91
|
+
|
92
|
+
@ui_util.screenshot_on_error
|
93
|
+
def test_edit_constant(self):
|
94
|
+
"""Test editing an existing constant."""
|
95
|
+
# Create a constant
|
96
|
+
db_util.create_constant("Constant Name", "Value")
|
97
|
+
ui_util.refresh_ui(self.browser)
|
98
|
+
|
99
|
+
# Click constant in table
|
100
|
+
ui_util.click_table_row(self.browser, "constants_tab_constants_table", 0)
|
101
|
+
|
102
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_value_input]").send_keys(" New")
|
103
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_save_button]").click()
|
104
|
+
time.sleep(1)
|
105
|
+
|
106
|
+
constant = db_util.get_constant("Constant Name")
|
107
|
+
self.assertEqual(constant.value, "Value New")
|
108
|
+
|
109
|
+
@ui_util.screenshot_on_error
|
110
|
+
def test_edit_credential(self):
|
111
|
+
"""Test editing an existing credential."""
|
112
|
+
# Create a credential
|
113
|
+
db_util.create_credential("Credential Name", "Username", "Password")
|
114
|
+
ui_util.refresh_ui(self.browser)
|
115
|
+
|
116
|
+
# Click credential in table
|
117
|
+
ui_util.click_table_row(self.browser, "constants_tab_credentials_table", 0)
|
118
|
+
|
119
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_username_input]").send_keys(" New")
|
120
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_password_input]").send_keys("Password New")
|
121
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_save_button]").click()
|
122
|
+
time.sleep(1)
|
123
|
+
|
124
|
+
# Make sure the encryption key matches the one in the ui
|
125
|
+
crypto_util.set_key(ui_util.ENCRYPTION_KEY)
|
126
|
+
|
127
|
+
credential = db_util.get_credential("Credential Name")
|
128
|
+
self.assertEqual(credential.username, "Username New")
|
129
|
+
self.assertEqual(credential.password, "Password New")
|
130
|
+
|
131
|
+
@ui_util.screenshot_on_error
|
132
|
+
def test_delete_constant(self):
|
133
|
+
"""Test deleting a constant."""
|
134
|
+
# Create a constant
|
135
|
+
db_util.create_constant("Constant Name", "Value")
|
136
|
+
ui_util.refresh_ui(self.browser)
|
137
|
+
|
138
|
+
# Click constant in table
|
139
|
+
ui_util.click_table_row(self.browser, "constants_tab_constants_table", 0)
|
140
|
+
|
141
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=constant_popup_delete_button]").click()
|
142
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=popup_option1_button]").click()
|
143
|
+
time.sleep(1)
|
144
|
+
|
145
|
+
with self.assertRaises(ValueError):
|
146
|
+
db_util.get_constant("Constant Name")
|
147
|
+
|
148
|
+
@ui_util.screenshot_on_error
|
149
|
+
def test_delete_credential(self):
|
150
|
+
"""Test deleting a credential."""
|
151
|
+
# Create a credential
|
152
|
+
db_util.create_credential("Credential Name", "Username", "Password")
|
153
|
+
ui_util.refresh_ui(self.browser)
|
154
|
+
|
155
|
+
# Click credential in table
|
156
|
+
ui_util.click_table_row(self.browser, "constants_tab_credentials_table", 0)
|
157
|
+
|
158
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=credential_popup_delete_button]").click()
|
159
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=popup_option1_button]").click()
|
160
|
+
time.sleep(1)
|
161
|
+
|
162
|
+
with self.assertRaises(ValueError):
|
163
|
+
db_util.get_credential("Credential Name")
|
164
|
+
|
165
|
+
|
166
|
+
if __name__ == '__main__':
|
167
|
+
unittest.main()
|
@@ -0,0 +1,180 @@
|
|
1
|
+
"""Tests relating to the logs tab in Orchestrator."""
|
2
|
+
|
3
|
+
import unittest
|
4
|
+
from datetime import datetime, timedelta
|
5
|
+
import time
|
6
|
+
|
7
|
+
from selenium.webdriver.common.by import By
|
8
|
+
from selenium.webdriver.common.keys import Keys
|
9
|
+
|
10
|
+
from OpenOrchestrator.tests import db_test_util
|
11
|
+
from OpenOrchestrator.database import db_util
|
12
|
+
from OpenOrchestrator.database.logs import LogLevel
|
13
|
+
from OpenOrchestrator.tests.ui_tests import ui_util
|
14
|
+
|
15
|
+
|
16
|
+
class TestLogsTab(unittest.TestCase):
|
17
|
+
"""Test functionality of the logs tab ui."""
|
18
|
+
def setUp(self) -> None:
|
19
|
+
self.browser = ui_util.open_orchestrator()
|
20
|
+
db_test_util.establish_clean_database()
|
21
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=logs_tab]").click()
|
22
|
+
ui_util.refresh_ui(self.browser)
|
23
|
+
|
24
|
+
def tearDown(self) -> None:
|
25
|
+
self.browser.quit()
|
26
|
+
|
27
|
+
@ui_util.screenshot_on_error
|
28
|
+
def test_logs_table(self):
|
29
|
+
"""Test that logs are shown correctly in the logs table."""
|
30
|
+
# Create some logs
|
31
|
+
self._create_logs()
|
32
|
+
|
33
|
+
ui_util.refresh_ui(self.browser)
|
34
|
+
|
35
|
+
# Check result
|
36
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
37
|
+
self.assertRegex(table_data[0][0], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
38
|
+
self.assertEqual(table_data[0][1], "Test Error")
|
39
|
+
self.assertEqual(table_data[0][2], LogLevel.ERROR.value)
|
40
|
+
self.assertEqual(table_data[0][3], "Error Message")
|
41
|
+
|
42
|
+
self.assertRegex(table_data[1][0], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
43
|
+
self.assertEqual(table_data[1][1], "Test Info")
|
44
|
+
self.assertEqual(table_data[1][2], LogLevel.INFO.value)
|
45
|
+
self.assertEqual(table_data[1][3], "Info Message")
|
46
|
+
|
47
|
+
self.assertRegex(table_data[2][0], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
48
|
+
self.assertEqual(table_data[2][1], "Test Trace")
|
49
|
+
self.assertEqual(table_data[2][2], LogLevel.TRACE.value)
|
50
|
+
self.assertEqual(table_data[2][3], "Trace Message")
|
51
|
+
|
52
|
+
@ui_util.screenshot_on_error
|
53
|
+
def test_date_filter(self):
|
54
|
+
"""Test filtering on date."""
|
55
|
+
yesterday = datetime.today() - timedelta(days=1)
|
56
|
+
tomorrow = datetime.today() + timedelta(days=1)
|
57
|
+
|
58
|
+
self._create_logs()
|
59
|
+
ui_util.refresh_ui(self.browser)
|
60
|
+
|
61
|
+
# No filter
|
62
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
63
|
+
self.assertEqual(len(table_data), 3)
|
64
|
+
|
65
|
+
# From yesterday
|
66
|
+
self._set_date_filter(from_date=yesterday, to_date=None)
|
67
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
68
|
+
self.assertEqual(len(table_data), 3)
|
69
|
+
|
70
|
+
# From tomorrow
|
71
|
+
self._set_date_filter(from_date=tomorrow, to_date=None)
|
72
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
73
|
+
self.assertEqual(len(table_data), 0)
|
74
|
+
|
75
|
+
# To yesterday
|
76
|
+
self._set_date_filter(from_date=None, to_date=yesterday)
|
77
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
78
|
+
self.assertEqual(len(table_data), 0)
|
79
|
+
|
80
|
+
# To tomorrow
|
81
|
+
self._set_date_filter(from_date=None, to_date=tomorrow)
|
82
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
83
|
+
self.assertEqual(len(table_data), 3)
|
84
|
+
|
85
|
+
# From yesterday To tomorrow
|
86
|
+
self._set_date_filter(from_date=yesterday, to_date=tomorrow)
|
87
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
88
|
+
self.assertEqual(len(table_data), 3)
|
89
|
+
|
90
|
+
# Clear filter
|
91
|
+
self._set_date_filter(None, None)
|
92
|
+
|
93
|
+
@ui_util.screenshot_on_error
|
94
|
+
def test_process_filter(self):
|
95
|
+
"""Test filtering on process name."""
|
96
|
+
self._create_logs()
|
97
|
+
|
98
|
+
self._set_process_filter(2)
|
99
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
100
|
+
self.assertEqual(table_data[0][1], "Test Error")
|
101
|
+
|
102
|
+
self._set_process_filter(3)
|
103
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
104
|
+
self.assertEqual(table_data[0][1], "Test Info")
|
105
|
+
|
106
|
+
self._set_process_filter(4)
|
107
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
108
|
+
self.assertEqual(table_data[0][1], "Test Trace")
|
109
|
+
|
110
|
+
self._set_process_filter(1)
|
111
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
112
|
+
self.assertEqual(len(table_data), 3)
|
113
|
+
|
114
|
+
@ui_util.screenshot_on_error
|
115
|
+
def test_level_filter(self):
|
116
|
+
"""Test filtering on log level."""
|
117
|
+
self._create_logs()
|
118
|
+
|
119
|
+
self._set_level_filter(2)
|
120
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
121
|
+
self.assertEqual(table_data[0][1], "Test Trace")
|
122
|
+
|
123
|
+
self._set_level_filter(3)
|
124
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
125
|
+
self.assertEqual(table_data[0][1], "Test Info")
|
126
|
+
|
127
|
+
self._set_level_filter(4)
|
128
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
129
|
+
self.assertEqual(table_data[0][1], "Test Error")
|
130
|
+
|
131
|
+
self._set_level_filter(1)
|
132
|
+
table_data = ui_util.get_table_data(self.browser, "logs_tab_logs_table")
|
133
|
+
self.assertEqual(len(table_data), 3)
|
134
|
+
|
135
|
+
def _set_date_filter(self, from_date: datetime | None, to_date: datetime | None):
|
136
|
+
# Clear filters
|
137
|
+
from_input = self.browser.find_element(By.CSS_SELECTOR, "[auto-id=logs_tab_from_input]")
|
138
|
+
from_input.send_keys(Keys.CONTROL, "a", Keys.DELETE)
|
139
|
+
to_input = self.browser.find_element(By.CSS_SELECTOR, "[auto-id=logs_tab_to_input]")
|
140
|
+
to_input.send_keys(Keys.CONTROL, "a", Keys.DELETE)
|
141
|
+
|
142
|
+
if from_date:
|
143
|
+
from_input.send_keys(from_date.strftime("%d-%m-%Y %H:%M"))
|
144
|
+
|
145
|
+
if to_date:
|
146
|
+
to_input.send_keys(to_date.strftime("%d-%m-%Y %H:%M"))
|
147
|
+
|
148
|
+
def _set_process_filter(self, index: int):
|
149
|
+
"""Select a process in the process filter.
|
150
|
+
|
151
|
+
Args:
|
152
|
+
index: The 1-based index of the process to choose.
|
153
|
+
"""
|
154
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=logs_tab_process_input]").click()
|
155
|
+
self.browser.find_element(By.XPATH, f"//div[@role='listbox']//div[contains(@class, 'q-item')][{index}]").click()
|
156
|
+
time.sleep(0.5)
|
157
|
+
|
158
|
+
def _set_level_filter(self, index: int):
|
159
|
+
"""Select a level in the level filter.
|
160
|
+
|
161
|
+
Args:
|
162
|
+
index: The 1-based index of the level to choose.
|
163
|
+
"""
|
164
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=logs_tab_level_input]").click()
|
165
|
+
self.browser.find_element(By.XPATH, f"//div[@role='listbox']//div[contains(@class, 'q-item')][{index}]").click()
|
166
|
+
time.sleep(0.5)
|
167
|
+
|
168
|
+
def _create_logs(self):
|
169
|
+
"""Create some logs for testing."""
|
170
|
+
db_util.create_log("Test Trace", LogLevel.TRACE, "Trace Message")
|
171
|
+
time.sleep(0.1)
|
172
|
+
db_util.create_log("Test Info", LogLevel.INFO, "Info Message")
|
173
|
+
time.sleep(0.1)
|
174
|
+
db_util.create_log("Test Error", LogLevel.ERROR, "Error Message")
|
175
|
+
|
176
|
+
ui_util.refresh_ui(self.browser)
|
177
|
+
|
178
|
+
|
179
|
+
if __name__ == '__main__':
|
180
|
+
unittest.main()
|
@@ -0,0 +1,126 @@
|
|
1
|
+
"""Tests relating to the queues tab in Orchestrator."""
|
2
|
+
|
3
|
+
import unittest
|
4
|
+
from datetime import datetime, timedelta
|
5
|
+
|
6
|
+
from selenium.webdriver.common.by import By
|
7
|
+
from selenium.webdriver.common.keys import Keys
|
8
|
+
|
9
|
+
from OpenOrchestrator.tests import db_test_util
|
10
|
+
from OpenOrchestrator.database import db_util
|
11
|
+
from OpenOrchestrator.database.queues import QueueStatus
|
12
|
+
from OpenOrchestrator.tests.ui_tests import ui_util
|
13
|
+
|
14
|
+
|
15
|
+
class TestQueuesTab(unittest.TestCase):
|
16
|
+
"""Test functionality of the queues tab ui."""
|
17
|
+
def setUp(self) -> None:
|
18
|
+
self.browser = ui_util.open_orchestrator()
|
19
|
+
db_test_util.establish_clean_database()
|
20
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=queues_tab]").click()
|
21
|
+
ui_util.refresh_ui(self.browser)
|
22
|
+
|
23
|
+
def tearDown(self) -> None:
|
24
|
+
self.browser.quit()
|
25
|
+
|
26
|
+
@ui_util.screenshot_on_error
|
27
|
+
def test_queues_table(self):
|
28
|
+
"""Test that queues are displayed correctly in the queues table."""
|
29
|
+
self._create_queue_elements()
|
30
|
+
ui_util.refresh_ui(self.browser)
|
31
|
+
|
32
|
+
table_data = ui_util.get_table_data(self.browser, "queues_tab_queue_table")
|
33
|
+
self.assertEqual(table_data[0], ["Queue Name 1", "1", "2", "3", "4", "5"])
|
34
|
+
self.assertEqual(table_data[1], ["Queue Name 2", "1", "2", "3", "4", "5"])
|
35
|
+
|
36
|
+
@ui_util.screenshot_on_error
|
37
|
+
def test_queue_popup(self):
|
38
|
+
"""Test that queue elements are displayed correctly in the queue popup."""
|
39
|
+
self._create_queue_elements()
|
40
|
+
ui_util.refresh_ui(self.browser)
|
41
|
+
|
42
|
+
ui_util.click_table_row(self.browser, "queues_tab_queue_table", 0)
|
43
|
+
|
44
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
45
|
+
|
46
|
+
queue_elements = db_util.get_queue_elements("Queue Name 1")
|
47
|
+
|
48
|
+
self.assertEqual(len(table_data), len(queue_elements))
|
49
|
+
for i, queue_element in enumerate(queue_elements):
|
50
|
+
self.assertIn(table_data[i][0], queue_element.reference)
|
51
|
+
self.assertEqual(table_data[i][1], queue_element.status.value)
|
52
|
+
self.assertEqual(table_data[i][2], queue_element.data)
|
53
|
+
self.assertEqual(table_data[i][3], queue_element.message)
|
54
|
+
self.assertRegex(table_data[i][4], r"(\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2})|(N/A)")
|
55
|
+
self.assertRegex(table_data[i][5], r"(\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2})|(N/A)")
|
56
|
+
self.assertRegex(table_data[i][6], r"(\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2})|(N/A)")
|
57
|
+
self.assertEqual(table_data[i][7], queue_element.created_by)
|
58
|
+
|
59
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=queue_popup_close_button]").click()
|
60
|
+
|
61
|
+
@ui_util.screenshot_on_error
|
62
|
+
def test_queue_popup_filters(self):
|
63
|
+
"""Test setting filters in the queue popup."""
|
64
|
+
self._create_queue_elements()
|
65
|
+
ui_util.refresh_ui(self.browser)
|
66
|
+
|
67
|
+
ui_util.click_table_row(self.browser, "queues_tab_queue_table", 0)
|
68
|
+
|
69
|
+
yesterday = datetime.today() - timedelta(days=1)
|
70
|
+
tomorrow = datetime.today() + timedelta(days=1)
|
71
|
+
|
72
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
73
|
+
self.assertEqual(len(table_data), 15)
|
74
|
+
|
75
|
+
# From yesterday
|
76
|
+
self._set_date_filter(from_date=yesterday, to_date=None)
|
77
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
78
|
+
self.assertEqual(len(table_data), 15)
|
79
|
+
|
80
|
+
# From tomorrow
|
81
|
+
self._set_date_filter(from_date=tomorrow, to_date=None)
|
82
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
83
|
+
self.assertEqual(len(table_data), 0)
|
84
|
+
|
85
|
+
# To yesterday
|
86
|
+
self._set_date_filter(from_date=None, to_date=yesterday)
|
87
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
88
|
+
self.assertEqual(len(table_data), 0)
|
89
|
+
|
90
|
+
# From yesterday to tomorrow
|
91
|
+
self._set_date_filter(from_date=yesterday, to_date=tomorrow)
|
92
|
+
table_data = ui_util.get_table_data(self.browser, "queue_popup_table")
|
93
|
+
self.assertEqual(len(table_data), 15)
|
94
|
+
|
95
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=queue_popup_close_button]").click()
|
96
|
+
|
97
|
+
def _create_queue_elements(self):
|
98
|
+
"""Create some queue elements.
|
99
|
+
Creates 1x'New', 2x'In Progress' and so on.
|
100
|
+
"""
|
101
|
+
for j in range(2):
|
102
|
+
for i, status in enumerate(QueueStatus):
|
103
|
+
for k in range(i+1):
|
104
|
+
qe = db_util.create_queue_element(f"Queue Name {j+1}", reference=f"Reference {k},{i}", data=f"Data {k},{i}", created_by=f"Creator {k},{i}")
|
105
|
+
db_util.set_queue_element_status(qe.id, status, message=f"Message {k},{i}")
|
106
|
+
|
107
|
+
# This code is similar to some in test_logging_tab.
|
108
|
+
# Since the ui might change it doesn't make sense to make a common function for this.
|
109
|
+
# pylint: disable=duplicate-code
|
110
|
+
def _set_date_filter(self, from_date: datetime | None, to_date: datetime | None):
|
111
|
+
"""Set the date filters."""
|
112
|
+
# Clear filters
|
113
|
+
from_input = self.browser.find_element(By.CSS_SELECTOR, "[auto-id=queue_popup_from_input]")
|
114
|
+
from_input.send_keys(Keys.CONTROL, "a", Keys.DELETE)
|
115
|
+
to_input = self.browser.find_element(By.CSS_SELECTOR, "[auto-id=queue_popup_to_input]")
|
116
|
+
to_input.send_keys(Keys.CONTROL, "a", Keys.DELETE)
|
117
|
+
|
118
|
+
if from_date:
|
119
|
+
from_input.send_keys(from_date.strftime("%d-%m-%Y %H:%M"))
|
120
|
+
|
121
|
+
if to_date:
|
122
|
+
to_input.send_keys(to_date.strftime("%d-%m-%Y %H:%M"))
|
123
|
+
|
124
|
+
|
125
|
+
if __name__ == '__main__':
|
126
|
+
unittest.main()
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"""Tests relating to the schedulers tab in Orchestrator."""
|
2
|
+
|
3
|
+
import unittest
|
4
|
+
|
5
|
+
from selenium.webdriver.common.by import By
|
6
|
+
|
7
|
+
from OpenOrchestrator.tests import db_test_util
|
8
|
+
from OpenOrchestrator.database import db_util
|
9
|
+
from OpenOrchestrator.tests.ui_tests import ui_util
|
10
|
+
|
11
|
+
|
12
|
+
class TestSchedulersTab(unittest.TestCase):
|
13
|
+
"""Test functionality of the schedulers tab ui."""
|
14
|
+
@classmethod
|
15
|
+
def setUpClass(cls) -> None:
|
16
|
+
cls.browser = ui_util.open_orchestrator()
|
17
|
+
|
18
|
+
@classmethod
|
19
|
+
def tearDownClass(cls) -> None:
|
20
|
+
cls.browser.quit()
|
21
|
+
|
22
|
+
def setUp(self) -> None:
|
23
|
+
db_test_util.establish_clean_database()
|
24
|
+
self.browser.find_element(By.CSS_SELECTOR, "[auto-id=schedulers_tab]").click()
|
25
|
+
ui_util.refresh_ui(self.browser)
|
26
|
+
|
27
|
+
@ui_util.screenshot_on_error
|
28
|
+
def test_schedulers_table(self):
|
29
|
+
"""Test that schedulers are shown correctly in the schedulers table."""
|
30
|
+
db_util.send_ping_from_scheduler("Testmachine")
|
31
|
+
db_util.start_trigger_from_machine("Testmachine2", "RPA Process")
|
32
|
+
ui_util.refresh_ui(self.browser)
|
33
|
+
|
34
|
+
# Check that the text content is displayed correctly
|
35
|
+
table_data = ui_util.get_table_data(self.browser, "schedulers_tab_schedulers_table")
|
36
|
+
self.assertEqual(table_data[0][0], "Testmachine")
|
37
|
+
self.assertRegex(table_data[0][1], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
38
|
+
self.assertEqual(table_data[0][2], "None yet")
|
39
|
+
|
40
|
+
self.assertEqual(table_data[1][0], "Testmachine2")
|
41
|
+
self.assertRegex(table_data[1][1], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
42
|
+
self.assertEqual(table_data[1][2], "RPA Process")
|
43
|
+
self.assertRegex(table_data[1][3], r"\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}")
|
44
|
+
|
45
|
+
|
46
|
+
if __name__ == '__main__':
|
47
|
+
unittest.main()
|