forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalerts_test.py
More file actions
49 lines (39 loc) · 1.63 KB
/
alerts_test.py
File metadata and controls
49 lines (39 loc) · 1.63 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
import sys
import unittest
from base_test_class import BaseTestCase, on_exception_html_source_logger
from selenium.webdriver.common.by import By
class AlertsTest(BaseTestCase):
@on_exception_html_source_logger
def test_alerts_page_loads(self):
driver = self.driver
driver.get(self.base_url + "alerts")
self.assertTrue(self.is_text_present_on_page(text="Alerts"))
@on_exception_html_source_logger
def test_alerts_page_with_no_alerts(self):
driver = self.driver
driver.get(self.base_url + "alerts")
# Page should load successfully even with no alerts
body_text = driver.find_element(By.TAG_NAME, "body").text
self.assertIsNotNone(body_text)
@on_exception_html_source_logger
def test_delete_all_alerts(self):
driver = self.driver
driver.get(self.base_url + "delete_alerts")
# After deleting all alerts, verify we're redirected or get success
# The page should redirect back to alerts
self.assertTrue(
self.is_text_present_on_page(text="Alerts")
or self.is_success_message_present(text="Alerts removed"),
)
def suite():
suite = unittest.TestSuite()
suite.addTest(BaseTestCase("test_login"))
suite.addTest(AlertsTest("test_alerts_page_loads"))
suite.addTest(AlertsTest("test_alerts_page_with_no_alerts"))
suite.addTest(AlertsTest("test_delete_all_alerts"))
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)