-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathaction_history_test.py
More file actions
81 lines (71 loc) · 3.08 KB
/
action_history_test.py
File metadata and controls
81 lines (71 loc) · 3.08 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
import sys
import time
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 ActionHistoryTest(BaseTestCase):
@on_exception_html_source_logger
def test_product_action_history(self):
"""Test the action history page for a product."""
driver = self.driver
self.goto_product_overview(driver)
driver.find_element(By.LINK_TEXT, "QA Test").click()
# Get the content type ID for Product
# Use the Django history URL pattern: history/<content_type_id>/<object_id>
# We can navigate to it via the product page's history link if available
driver.find_element(By.ID, "dropdownMenu1").click()
time.sleep(0.5)
history_links = driver.find_elements(By.LINK_TEXT, "History")
if len(history_links) > 0:
history_links[0].click()
time.sleep(1)
self.assertTrue(
self.is_text_present_on_page(text="History")
or self.is_text_present_on_page(text="history")
or self.is_text_present_on_page(text="Action"),
)
else:
# History link might not be in dropdown, just verify no error
self.assertFalse(self.is_error_message_present())
@on_exception_html_source_logger
def test_components_page_loads(self):
"""Test the global components page loads."""
driver = self.driver
driver.get(self.base_url + "components")
time.sleep(1)
self.assertTrue(
self.is_text_present_on_page(text="Component")
or self.is_text_present_on_page(text="component"),
)
@on_exception_html_source_logger
def test_product_components_page(self):
"""Test the product components page."""
driver = self.driver
self.goto_product_overview(driver)
driver.find_element(By.LINK_TEXT, "QA Test").click()
current_url = driver.current_url
parts = current_url.rstrip("/").split("/")
pid = parts[-1]
driver.get(self.base_url + f"product/{pid}/components")
time.sleep(1)
self.assertTrue(
self.is_text_present_on_page(text="Component")
or self.is_text_present_on_page(text="QA Test"),
)
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(ActionHistoryTest("test_product_action_history"))
suite.addTest(ActionHistoryTest("test_components_page_loads"))
suite.addTest(ActionHistoryTest("test_product_components_page"))
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)