summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/tests/functional/test_project_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/tests/functional/test_project_config.py')
-rw-r--r--bitbake/lib/toaster/tests/functional/test_project_config.py97
1 files changed, 25 insertions, 72 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_project_config.py b/bitbake/lib/toaster/tests/functional/test_project_config.py
index dbee36aa4e..fcb1bc3284 100644
--- a/bitbake/lib/toaster/tests/functional/test_project_config.py
+++ b/bitbake/lib/toaster/tests/functional/test_project_config.py
@@ -7,7 +7,6 @@
7# 7#
8 8
9import string 9import string
10import random
11import pytest 10import pytest
12from django.urls import reverse 11from django.urls import reverse
13from selenium.webdriver import Keys 12from selenium.webdriver import Keys
@@ -18,9 +17,6 @@ from selenium.webdriver.common.by import By
18 17
19from .utils import get_projectId_from_url 18from .utils import get_projectId_from_url
20 19
21
22@pytest.mark.django_db
23@pytest.mark.order("last")
24class TestProjectConfig(SeleniumFunctionalTestCase): 20class TestProjectConfig(SeleniumFunctionalTestCase):
25 project_id = None 21 project_id = None
26 PROJECT_NAME = 'TestProjectConfig' 22 PROJECT_NAME = 'TestProjectConfig'
@@ -28,42 +24,6 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
28 INVALID_PATH_CHAR_TEXT = 'The directory path cannot include spaces or ' \ 24 INVALID_PATH_CHAR_TEXT = 'The directory path cannot include spaces or ' \
29 'any of these characters' 25 'any of these characters'
30 26
31 def _create_project(self, project_name):
32 """ Create/Test new project using:
33 - Project Name: Any string
34 - Release: Any string
35 - Merge Toaster settings: True or False
36 """
37 self.get(reverse('newproject'))
38 self.wait_until_visible('#new-project-name', poll=2)
39 self.find("#new-project-name").send_keys(project_name)
40 select = Select(self.find("#projectversion"))
41 select.select_by_value('3')
42
43 # check merge toaster settings
44 checkbox = self.find('.checkbox-mergeattr')
45 if not checkbox.is_selected():
46 checkbox.click()
47
48 if self.PROJECT_NAME != 'TestProjectConfig':
49 # Reset project name if it's not the default one
50 self.PROJECT_NAME = 'TestProjectConfig'
51
52 self.find("#create-project-button").click()
53
54 try:
55 self.wait_until_visible('#hint-error-project-name', poll=2)
56 url = reverse('project', args=(TestProjectConfig.project_id, ))
57 self.get(url)
58 self.wait_until_visible('#config-nav', poll=3)
59 except TimeoutException:
60 self.wait_until_visible('#config-nav', poll=3)
61
62 def _random_string(self, length):
63 return ''.join(
64 random.choice(string.ascii_letters) for _ in range(length)
65 )
66
67 def _get_config_nav_item(self, index): 27 def _get_config_nav_item(self, index):
68 config_nav = self.find('#config-nav') 28 config_nav = self.find('#config-nav')
69 return config_nav.find_elements(By.TAG_NAME, 'li')[index] 29 return config_nav.find_elements(By.TAG_NAME, 'li')[index]
@@ -72,16 +32,14 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
72 """ Navigate to project BitBake variables page """ 32 """ Navigate to project BitBake variables page """
73 # check if the menu is displayed 33 # check if the menu is displayed
74 if TestProjectConfig.project_id is None: 34 if TestProjectConfig.project_id is None:
75 self._create_project(project_name=self._random_string(10)) 35 TestProjectConfig.project_id = self.create_new_project(self.PROJECT_NAME, '3', None, True)
76 current_url = self.driver.current_url 36
77 TestProjectConfig.project_id = get_projectId_from_url(current_url) 37 url = reverse('projectconf', args=(TestProjectConfig.project_id,))
78 else: 38 self.get(url)
79 url = reverse('projectconf', args=(TestProjectConfig.project_id,)) 39 self.wait_until_visible('#config-nav')
80 self.get(url)
81 self.wait_until_visible('#config-nav', poll=3)
82 bbv_page_link = self._get_config_nav_item(9) 40 bbv_page_link = self._get_config_nav_item(9)
83 bbv_page_link.click() 41 bbv_page_link.click()
84 self.wait_until_visible('#config-nav', poll=3) 42 self.wait_until_visible('#config-nav')
85 43
86 def test_no_underscore_iamgefs_type(self): 44 def test_no_underscore_iamgefs_type(self):
87 """ 45 """
@@ -90,13 +48,13 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
90 self._navigate_bbv_page() 48 self._navigate_bbv_page()
91 imagefs_type = "foo_bar" 49 imagefs_type = "foo_bar"
92 50
93 self.wait_until_visible('#change-image_fstypes-icon', poll=2) 51 self.wait_until_visible('#change-image_fstypes-icon')
94 52
95 self.click('#change-image_fstypes-icon') 53 self.click('#change-image_fstypes-icon')
96 54
97 self.enter_text('#new-imagefs_types', imagefs_type) 55 self.enter_text('#new-imagefs_types', imagefs_type)
98 56
99 element = self.wait_until_visible('#hintError-image-fs_type', poll=2) 57 element = self.wait_until_visible('#hintError-image-fs_type')
100 58
101 self.assertTrue(("A valid image type cannot include underscores" in element.text), 59 self.assertTrue(("A valid image type cannot include underscores" in element.text),
102 "Did not find underscore error message") 60 "Did not find underscore error message")
@@ -110,7 +68,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
110 68
111 imagefs_type = "btrfs" 69 imagefs_type = "btrfs"
112 70
113 self.wait_until_visible('#change-image_fstypes-icon', poll=2) 71 self.wait_until_visible('#change-image_fstypes-icon')
114 72
115 self.click('#change-image_fstypes-icon') 73 self.click('#change-image_fstypes-icon')
116 74
@@ -129,22 +87,20 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
129 """ 87 """
130 self._navigate_bbv_page() 88 self._navigate_bbv_page()
131 89
132 self.wait_until_visible('#change-image_fstypes-icon', poll=2) 90 self.wait_until_visible('#change-image_fstypes-icon')
133
134 self.click('#change-image_fstypes-icon') 91 self.click('#change-image_fstypes-icon')
135 92
136 checkboxes_selector = '.fs-checkbox-fstypes' 93 checkboxes_selector = '.fs-checkbox-fstypes'
137 94
138 self.wait_until_visible(checkboxes_selector, poll=2) 95 self.wait_until_visible(checkboxes_selector)
139 checkboxes = self.find_all(checkboxes_selector) 96 checkboxes = self.find_all(checkboxes_selector)
140 97
141 for checkbox in checkboxes: 98 for checkbox in checkboxes:
142 if checkbox.get_attribute("value") == "cpio": 99 if checkbox.get_attribute("value") == "cpio":
143 checkbox.click() 100 checkbox.click()
101 self.wait_until_visible('#new-imagefs_types')
144 element = self.driver.find_element(By.ID, 'new-imagefs_types') 102 element = self.driver.find_element(By.ID, 'new-imagefs_types')
145 103
146 self.wait_until_visible('#new-imagefs_types', poll=2)
147
148 self.assertTrue(("cpio" in element.get_attribute('value'), 104 self.assertTrue(("cpio" in element.get_attribute('value'),
149 "Imagefs not added into the textbox")) 105 "Imagefs not added into the textbox"))
150 checkbox.click() 106 checkbox.click()
@@ -160,20 +116,19 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
160 116
161 # activate the input to edit download dir 117 # activate the input to edit download dir
162 try: 118 try:
163 change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) 119 change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon')
164 except TimeoutException: 120 except TimeoutException:
165 # If download dir is not displayed, test is skipped 121 # If download dir is not displayed, test is skipped
166 change_dl_dir_btn = None 122 change_dl_dir_btn = None
167 123
168 if change_dl_dir_btn: 124 if change_dl_dir_btn:
169 change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2)
170 change_dl_dir_btn.click() 125 change_dl_dir_btn.click()
171 126
172 # downloads dir path doesn't start with / or ${...} 127 # downloads dir path doesn't start with / or ${...}
173 input_field = self.wait_until_visible('#new-dl_dir', poll=2) 128 input_field = self.wait_until_visible('#new-dl_dir')
174 input_field.clear() 129 input_field.clear()
175 self.enter_text('#new-dl_dir', 'home/foo') 130 self.enter_text('#new-dl_dir', 'home/foo')
176 element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) 131 element = self.wait_until_visible('#hintError-initialChar-dl_dir')
177 132
178 msg = 'downloads directory path starts with invalid character but ' \ 133 msg = 'downloads directory path starts with invalid character but ' \
179 'treated as valid' 134 'treated as valid'
@@ -183,7 +138,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
183 self.driver.find_element(By.ID, 'new-dl_dir').clear() 138 self.driver.find_element(By.ID, 'new-dl_dir').clear()
184 self.enter_text('#new-dl_dir', '/foo/bar a') 139 self.enter_text('#new-dl_dir', '/foo/bar a')
185 140
186 element = self.wait_until_visible('#hintError-dl_dir', poll=2) 141 element = self.wait_until_visible('#hintError-dl_dir')
187 msg = 'downloads directory path characters invalid but treated as valid' 142 msg = 'downloads directory path characters invalid but treated as valid'
188 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) 143 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg)
189 144
@@ -191,7 +146,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
191 self.driver.find_element(By.ID,'new-dl_dir').clear() 146 self.driver.find_element(By.ID,'new-dl_dir').clear()
192 self.enter_text('#new-dl_dir', '${TOPDIR}/down foo') 147 self.enter_text('#new-dl_dir', '${TOPDIR}/down foo')
193 148
194 element = self.wait_until_visible('#hintError-dl_dir', poll=2) 149 element = self.wait_until_visible('#hintError-dl_dir')
195 msg = 'downloads directory path characters invalid but treated as valid' 150 msg = 'downloads directory path characters invalid but treated as valid'
196 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) 151 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg)
197 152
@@ -219,10 +174,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
219 self._navigate_bbv_page() 174 self._navigate_bbv_page()
220 175
221 try: 176 try:
222 btn_chg_sstate_dir = self.wait_until_visible( 177 btn_chg_sstate_dir = self.wait_until_visible('#change-sstate_dir-icon')
223 '#change-sstate_dir-icon',
224 poll=2
225 )
226 self.click('#change-sstate_dir-icon') 178 self.click('#change-sstate_dir-icon')
227 except TimeoutException: 179 except TimeoutException:
228 # If sstate_dir is not displayed, test is skipped 180 # If sstate_dir is not displayed, test is skipped
@@ -230,10 +182,10 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
230 182
231 if btn_chg_sstate_dir: # Skip continuation if sstate_dir is not displayed 183 if btn_chg_sstate_dir: # Skip continuation if sstate_dir is not displayed
232 # path doesn't start with / or ${...} 184 # path doesn't start with / or ${...}
233 input_field = self.wait_until_visible('#new-sstate_dir', poll=2) 185 input_field = self.wait_until_visible('#new-sstate_dir')
234 input_field.clear() 186 input_field.clear()
235 self.enter_text('#new-sstate_dir', 'home/foo') 187 self.enter_text('#new-sstate_dir', 'home/foo')
236 element = self.wait_until_visible('#hintError-initialChar-sstate_dir', poll=2) 188 element = self.wait_until_visible('#hintError-initialChar-sstate_dir')
237 189
238 msg = 'sstate directory path starts with invalid character but ' \ 190 msg = 'sstate directory path starts with invalid character but ' \
239 'treated as valid' 191 'treated as valid'
@@ -243,7 +195,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
243 self.driver.find_element(By.ID, 'new-sstate_dir').clear() 195 self.driver.find_element(By.ID, 'new-sstate_dir').clear()
244 self.enter_text('#new-sstate_dir', '/foo/bar a') 196 self.enter_text('#new-sstate_dir', '/foo/bar a')
245 197
246 element = self.wait_until_visible('#hintError-sstate_dir', poll=2) 198 element = self.wait_until_visible('#hintError-sstate_dir')
247 msg = 'sstate directory path characters invalid but treated as valid' 199 msg = 'sstate directory path characters invalid but treated as valid'
248 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) 200 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg)
249 201
@@ -251,7 +203,7 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
251 self.driver.find_element(By.ID,'new-sstate_dir').clear() 203 self.driver.find_element(By.ID,'new-sstate_dir').clear()
252 self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo') 204 self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo')
253 205
254 element = self.wait_until_visible('#hintError-sstate_dir', poll=2) 206 element = self.wait_until_visible('#hintError-sstate_dir')
255 msg = 'sstate directory path characters invalid but treated as valid' 207 msg = 'sstate directory path characters invalid but treated as valid'
256 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) 208 self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg)
257 209
@@ -275,13 +227,14 @@ class TestProjectConfig(SeleniumFunctionalTestCase):
275 var_name, field, btn_id, input_id, value, save_btn, *_ = kwargs.values() 227 var_name, field, btn_id, input_id, value, save_btn, *_ = kwargs.values()
276 """ Change bitbake variable value """ 228 """ Change bitbake variable value """
277 self._navigate_bbv_page() 229 self._navigate_bbv_page()
278 self.wait_until_visible(f'#{btn_id}', poll=2) 230 self.wait_until_visible(f'#{btn_id}')
279 if kwargs.get('new_variable'): 231 if kwargs.get('new_variable'):
280 self.find(f"#{btn_id}").clear() 232 self.find(f"#{btn_id}").clear()
281 self.enter_text(f"#{btn_id}", f"{var_name}") 233 self.enter_text(f"#{btn_id}", f"{var_name}")
282 else: 234 else:
283 self.click(f'#{btn_id}') 235 self.click(f'#{btn_id}')
284 self.wait_until_visible(f'#{input_id}', poll=2) 236
237 self.wait_until_visible(f'#{input_id}')
285 238
286 if kwargs.get('is_select'): 239 if kwargs.get('is_select'):
287 select = Select(self.find(f'#{input_id}')) 240 select = Select(self.find(f'#{input_id}'))