forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote_type_test.py
65 lines (51 loc) · 2.67 KB
/
note_type_test.py
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
import unittest
import sys
from base_test_class import BaseTestCase
from selenium.webdriver.common.by import By
class NoteTypeTest(BaseTestCase):
def test_create_note_type(self):
driver = self.driver
driver.get(self.base_url + "note_type")
driver.find_element(By.ID, "dropdownMenu1").click()
driver.find_element(By.LINK_TEXT, "Add Note Type").click()
driver.find_element(By.ID, "id_name").clear()
driver.find_element(By.ID, "id_name").send_keys("test note type")
driver.find_element(By.ID, "id_description").clear()
driver.find_element(By.ID, "id_description").send_keys("Test note type description")
driver.find_element(By.ID, "id_is_single").click()
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Note Type added successfully.'))
def test_edit_note_type(self):
driver = self.driver
driver.get(self.base_url + "note_type")
driver.find_element(By.LINK_TEXT, "Edit Note Type").click()
driver.find_element(By.ID, "id_name").clear()
driver.find_element(By.ID, "id_name").send_keys("Edited test note type")
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Note type updated successfully.'))
def test_disable_note_type(self):
driver = self.driver
driver.get(self.base_url + "note_type")
driver.find_element(By.LINK_TEXT, "Disable Note Type").click()
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-danger").click()
self.assertTrue(self.is_success_message_present(text='Note type Disabled successfully.'))
def test_enable_note_type(self):
driver = self.driver
driver.get(self.base_url + "note_type")
driver.find_element(By.LINK_TEXT, "Enable Note Type").click()
driver.find_element(By.CSS_SELECTOR, "input.btn.btn-success").click()
self.assertTrue(self.is_success_message_present(text='Note type Enabled successfully.'))
def suite():
suite = unittest.TestSuite()
suite.addTest(BaseTestCase('test_login'))
suite.addTest(BaseTestCase('disable_block_execution'))
suite.addTest(NoteTypeTest('test_create_note_type'))
suite.addTest(NoteTypeTest('test_edit_note_type'))
suite.addTest(NoteTypeTest('test_disable_note_type'))
suite.addTest(NoteTypeTest('test_enable_note_type'))
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)