forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard_test.py
More file actions
67 lines (55 loc) · 2.56 KB
/
dashboard_test.py
File metadata and controls
67 lines (55 loc) · 2.56 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
import sys
import unittest
from base_test_class import BaseTestCase, on_exception_html_source_logger, set_suite_settings
from product_test import ProductTest
from selenium.webdriver.common.by import By
class DashboardTest(BaseTestCase):
@on_exception_html_source_logger
def test_dashboard_loads(self):
driver = self.driver
driver.get(self.base_url)
# Verify the page loaded by checking for dashboard content
self.assertTrue(self.is_text_present_on_page(text="Active Engagements"))
@on_exception_html_source_logger
def test_dashboard_explicit_url(self):
driver = self.driver
driver.get(self.base_url + "dashboard")
self.assertTrue(self.is_text_present_on_page(text="Active Engagements"))
@on_exception_html_source_logger
def test_support_page_loads(self):
driver = self.driver
driver.get(self.base_url + "support")
self.assertTrue(self.is_text_present_on_page(text="Support"))
@on_exception_html_source_logger
def test_dashboard_contains_widgets(self):
driver = self.driver
driver.get(self.base_url + "dashboard")
# Verify dashboard contains key elements
body_text = driver.find_element(By.TAG_NAME, "body").text
# The dashboard should display some metrics or status info
self.assertIsNotNone(body_text)
self.assertTrue(len(body_text) > 0)
@on_exception_html_source_logger
def test_dashboard_with_product_data(self):
driver = self.driver
driver.get(self.base_url + "dashboard")
# After product and finding creation, dashboard should reflect data
self.assertTrue(self.is_text_present_on_page(text="Active Engagements"))
def suite():
suite = unittest.TestSuite()
suite.addTest(BaseTestCase("test_login"))
set_suite_settings(suite, jira=False, github=False, block_execution=False)
suite.addTest(ProductTest("test_create_product"))
suite.addTest(ProductTest("test_add_product_finding"))
suite.addTest(DashboardTest("test_dashboard_loads"))
suite.addTest(DashboardTest("test_dashboard_explicit_url"))
suite.addTest(DashboardTest("test_support_page_loads"))
suite.addTest(DashboardTest("test_dashboard_contains_widgets"))
suite.addTest(DashboardTest("test_dashboard_with_product_data"))
suite.addTest(ProductTest("test_delete_product"))
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)