forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_type_test.py
More file actions
82 lines (70 loc) · 3.21 KB
/
test_type_test.py
File metadata and controls
82 lines (70 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import sys
import time
import unittest
from base_test_class import BaseTestCase, on_exception_html_source_logger, set_suite_settings
from selenium.webdriver.common.by import By
class TestTypeTest(BaseTestCase):
@on_exception_html_source_logger
def test_list_test_types(self):
driver = self.driver
driver.get(self.base_url + "test_type")
self.assertTrue(self.is_text_present_on_page(text="Test Type List"))
@on_exception_html_source_logger
def test_add_test_type(self):
driver = self.driver
driver.get(self.base_url + "test_type/add")
time.sleep(1)
driver.find_element(By.ID, "id_name").clear()
driver.find_element(By.ID, "id_name").send_keys("Integration Test Type")
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-primary").click()
self.assertTrue(
self.is_success_message_present(text="Test type added successfully")
or self.is_text_present_on_page(text="Test Type List"),
)
@on_exception_html_source_logger
def test_edit_test_type(self):
driver = self.driver
driver.get(self.base_url + "test_type")
time.sleep(1)
# Find the test type we created and edit it
edit_links = driver.find_elements(By.LINK_TEXT, "Integration Test Type")
if len(edit_links) > 0:
edit_links[0].click()
time.sleep(1)
driver.find_element(By.ID, "id_name").clear()
driver.find_element(By.ID, "id_name").send_keys("Integration Test Type Edited")
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-primary").click()
self.assertTrue(
self.is_success_message_present(text="Test type updated successfully")
or self.is_text_present_on_page(text="Test Type List"),
)
else:
# If we can't find it, just verify page loaded
self.assertTrue(self.is_text_present_on_page(text="Test Type List"))
@on_exception_html_source_logger
def test_filter_test_types(self):
driver = self.driver
# Use a direct URL with filter query parameter instead of interacting
# with the collapsed filter panel, which can be non-interactable
driver.get(self.base_url + "test_type?name=Integration")
time.sleep(1)
self.assertTrue(self.is_text_present_on_page(text="Test Type List"))
# Verify our test type appears in the filtered results
self.assertTrue(
self.is_text_present_on_page(text="Integration Test Type")
or self.is_text_present_on_page(text="No test types found"),
)
def suite():
suite = unittest.TestSuite()
suite.addTest(BaseTestCase("test_login"))
set_suite_settings(suite, jira=False, github=False, block_execution=False)
suite.addTest(TestTypeTest("test_list_test_types"))
suite.addTest(TestTypeTest("test_add_test_type"))
suite.addTest(TestTypeTest("test_edit_test_type"))
suite.addTest(TestTypeTest("test_filter_test_types"))
return suite
if __name__ == "__main__":
runner = unittest.TextTestRunner(descriptions=True, failfast=True, verbosity=2)
ret = not runner.run(suite()).wasSuccessful()
BaseTestCase.tearDownDriver()
sys.exit(ret)