summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlassane Yattara <alassane.yattara@savoirfairelinux.com>2023-12-08 02:55:57 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-08 17:17:42 +0000
commit7fefb8588894b37ba8d7064385d10a2b7b568290 (patch)
tree7becb3f3770d85d8a0fab62e86767084548c9187
parent6d91225651573ab19b81a4430bccfc85f05a8173 (diff)
downloadpoky-7fefb8588894b37ba8d7064385d10a2b7b568290.tar.gz
bitbake: toaster/tests: bug-fix tests writing files into /tmp on the autobuilders
- Use build directory instead of /tmp - Better handle delay between driver actions (Bitbake rev: 234b125c11e4cca015e4d54fbddbfd3d276b88f6) Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/tests/browser/test_all_builds_page.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_all_projects_page.py45
-rw-r--r--bitbake/lib/toaster/tests/browser/test_builddashboard_page.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_landing_page.py33
-rw-r--r--bitbake/lib/toaster/tests/browser/test_layerdetails_page.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py1
-rw-r--r--bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py3
-rw-r--r--bitbake/lib/toaster/tests/browser/test_new_project_page.py11
-rw-r--r--bitbake/lib/toaster/tests/browser/test_project_builds_page.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_project_config_page.py4
-rw-r--r--bitbake/lib/toaster/tests/browser/test_toastertable_ui.py4
-rw-r--r--bitbake/lib/toaster/tests/views/test_views.py8
13 files changed, 74 insertions, 55 deletions
diff --git a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
index bfd8f3a439..7019b3dbec 100644
--- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
@@ -7,6 +7,7 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10import re 11import re
11 12
12from django.urls import reverse 13from django.urls import reverse
@@ -27,7 +28,8 @@ class TestAllBuildsPage(SeleniumTestCase):
27 CLI_BUILDS_PROJECT_NAME = 'command line builds' 28 CLI_BUILDS_PROJECT_NAME = 'command line builds'
28 29
29 def setUp(self): 30 def setUp(self):
30 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/', 31 builldir = os.environ.get('BUILDDIR', './')
32 bbv = BitbakeVersion.objects.create(name='bbv1', giturl=f'{builldir}/',
31 branch='master', dirpath='') 33 branch='master', dirpath='')
32 release = Release.objects.create(name='release1', 34 release = Release.objects.create(name='release1',
33 bitbake_version=bbv) 35 bitbake_version=bbv)
diff --git a/bitbake/lib/toaster/tests/browser/test_all_projects_page.py b/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
index a880dbcc68..6540dfa99c 100644
--- a/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
@@ -7,8 +7,8 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10import re 11import re
11import time
12 12
13from django.urls import reverse 13from django.urls import reverse
14from django.utils import timezone 14from django.utils import timezone
@@ -20,6 +20,7 @@ from orm.models import ProjectVariable
20 20
21from selenium.webdriver.common.by import By 21from selenium.webdriver.common.by import By
22 22
23
23class TestAllProjectsPage(SeleniumTestCase): 24class TestAllProjectsPage(SeleniumTestCase):
24 """ Browser tests for projects page /projects/ """ 25 """ Browser tests for projects page /projects/ """
25 26
@@ -29,7 +30,8 @@ class TestAllProjectsPage(SeleniumTestCase):
29 30
30 def setUp(self): 31 def setUp(self):
31 """ Add default project manually """ 32 """ Add default project manually """
32 project = Project.objects.create_project(self.CLI_BUILDS_PROJECT_NAME, None) 33 project = Project.objects.create_project(
34 self.CLI_BUILDS_PROJECT_NAME, None)
33 self.default_project = project 35 self.default_project = project
34 self.default_project.is_default = True 36 self.default_project.is_default = True
35 self.default_project.save() 37 self.default_project.save()
@@ -60,12 +62,14 @@ class TestAllProjectsPage(SeleniumTestCase):
60 62
61 def _add_non_default_project(self): 63 def _add_non_default_project(self):
62 """ Add another project """ 64 """ Add another project """
63 bbv = BitbakeVersion.objects.create(name='test bbv', giturl='/tmp/', 65 builldir = os.environ.get('BUILDDIR', './')
66 bbv = BitbakeVersion.objects.create(name='test bbv', giturl=f'{builldir}/',
64 branch='master', dirpath='') 67 branch='master', dirpath='')
65 self.release = Release.objects.create(name='test release', 68 self.release = Release.objects.create(name='test release',
66 branch_name='master', 69 branch_name='master',
67 bitbake_version=bbv) 70 bitbake_version=bbv)
68 self.project = Project.objects.create_project(self.PROJECT_NAME, self.release) 71 self.project = Project.objects.create_project(
72 self.PROJECT_NAME, self.release)
69 self.project.is_default = False 73 self.project.is_default = False
70 self.project.save() 74 self.project.save()
71 75
@@ -77,7 +81,7 @@ class TestAllProjectsPage(SeleniumTestCase):
77 81
78 def _get_row_for_project(self, project_name): 82 def _get_row_for_project(self, project_name):
79 """ Get the HTML row for a project, or None if not found """ 83 """ Get the HTML row for a project, or None if not found """
80 self.wait_until_present('#projectstable tbody tr') 84 self.wait_until_visible('#projectstable tbody tr', poll=3)
81 rows = self.find_all('#projectstable tbody tr') 85 rows = self.find_all('#projectstable tbody tr')
82 86
83 # find the row with a project name matching the one supplied 87 # find the row with a project name matching the one supplied
@@ -108,7 +112,8 @@ class TestAllProjectsPage(SeleniumTestCase):
108 url = reverse('all-projects') 112 url = reverse('all-projects')
109 self.get(url) 113 self.get(url)
110 114
111 default_project_row = self._get_row_for_project(self.default_project.name) 115 default_project_row = self._get_row_for_project(
116 self.default_project.name)
112 117
113 self.assertNotEqual(default_project_row, None, 118 self.assertNotEqual(default_project_row, None,
114 'default project "cli builds" should be in page') 119 'default project "cli builds" should be in page')
@@ -128,7 +133,8 @@ class TestAllProjectsPage(SeleniumTestCase):
128 self.wait_until_visible("#projectstable tr") 133 self.wait_until_visible("#projectstable tr")
129 134
130 # find the row for the default project 135 # find the row for the default project
131 default_project_row = self._get_row_for_project(self.default_project.name) 136 default_project_row = self._get_row_for_project(
137 self.default_project.name)
132 138
133 # check the release text for the default project 139 # check the release text for the default project
134 selector = 'span[data-project-field="release"] span.text-muted' 140 selector = 'span[data-project-field="release"] span.text-muted'
@@ -163,7 +169,8 @@ class TestAllProjectsPage(SeleniumTestCase):
163 self.wait_until_visible("#projectstable tr") 169 self.wait_until_visible("#projectstable tr")
164 170
165 # find the row for the default project 171 # find the row for the default project
166 default_project_row = self._get_row_for_project(self.default_project.name) 172 default_project_row = self._get_row_for_project(
173 self.default_project.name)
167 174
168 # check the machine cell for the default project 175 # check the machine cell for the default project
169 selector = 'span[data-project-field="machine"] span.text-muted' 176 selector = 'span[data-project-field="machine"] span.text-muted'
@@ -198,13 +205,15 @@ class TestAllProjectsPage(SeleniumTestCase):
198 self.get(reverse('all-projects')) 205 self.get(reverse('all-projects'))
199 206
200 # find the row for the default project 207 # find the row for the default project
201 default_project_row = self._get_row_for_project(self.default_project.name) 208 default_project_row = self._get_row_for_project(
209 self.default_project.name)
202 210
203 # check the link on the name field 211 # check the link on the name field
204 selector = 'span[data-project-field="name"] a' 212 selector = 'span[data-project-field="name"] a'
205 element = default_project_row.find_element(By.CSS_SELECTOR, selector) 213 element = default_project_row.find_element(By.CSS_SELECTOR, selector)
206 link_url = element.get_attribute('href').strip() 214 link_url = element.get_attribute('href').strip()
207 expected_url = reverse('projectbuilds', args=(self.default_project.id,)) 215 expected_url = reverse(
216 'projectbuilds', args=(self.default_project.id,))
208 msg = 'link on default project name should point to builds but was %s' % link_url 217 msg = 'link on default project name should point to builds but was %s' % link_url
209 self.assertTrue(link_url.endswith(expected_url), msg) 218 self.assertTrue(link_url.endswith(expected_url), msg)
210 219
@@ -227,7 +236,7 @@ class TestAllProjectsPage(SeleniumTestCase):
227 self.get(url) 236 self.get(url)
228 237
229 # Chseck search box is present and works 238 # Chseck search box is present and works
230 self.wait_until_present('#projectstable tbody tr') 239 self.wait_until_visible('#projectstable tbody tr', poll=3)
231 search_box = self.find('#search-input-projectstable') 240 search_box = self.find('#search-input-projectstable')
232 self.assertTrue(search_box.is_displayed()) 241 self.assertTrue(search_box.is_displayed())
233 242
@@ -235,8 +244,7 @@ class TestAllProjectsPage(SeleniumTestCase):
235 search_box.send_keys('test project 10') 244 search_box.send_keys('test project 10')
236 search_btn = self.find('#search-submit-projectstable') 245 search_btn = self.find('#search-submit-projectstable')
237 search_btn.click() 246 search_btn.click()
238 self.wait_until_present('#projectstable tbody tr') 247 self.wait_until_visible('#projectstable tbody tr', poll=3)
239 time.sleep(1)
240 rows = self.find_all('#projectstable tbody tr') 248 rows = self.find_all('#projectstable tbody tr')
241 self.assertTrue(len(rows) == 1) 249 self.assertTrue(len(rows) == 1)
242 250
@@ -282,7 +290,7 @@ class TestAllProjectsPage(SeleniumTestCase):
282 ) 290 )
283 url = reverse('all-projects') 291 url = reverse('all-projects')
284 self.get(url) 292 self.get(url)
285 self.wait_until_present('#projectstable tbody tr') 293 self.wait_until_visible('#projectstable tbody tr', poll=3)
286 294
287 # Check edit column 295 # Check edit column
288 edit_column = self.find('#edit-columns-button') 296 edit_column = self.find('#edit-columns-button')
@@ -305,19 +313,14 @@ class TestAllProjectsPage(SeleniumTestCase):
305 def test_show_rows(row_to_show, show_row_link): 313 def test_show_rows(row_to_show, show_row_link):
306 # Check that we can show rows == row_to_show 314 # Check that we can show rows == row_to_show
307 show_row_link.select_by_value(str(row_to_show)) 315 show_row_link.select_by_value(str(row_to_show))
308 self.wait_until_present('#projectstable tbody tr') 316 self.wait_until_visible('#projectstable tbody tr', poll=3)
309 sleep_time = 1
310 if row_to_show == 150:
311 # wait more time for 150 rows
312 sleep_time = 2
313 time.sleep(sleep_time)
314 self.assertTrue( 317 self.assertTrue(
315 len(self.find_all('#projectstable tbody tr')) == row_to_show 318 len(self.find_all('#projectstable tbody tr')) == row_to_show
316 ) 319 )
317 320
318 url = reverse('all-projects') 321 url = reverse('all-projects')
319 self.get(url) 322 self.get(url)
320 self.wait_until_present('#projectstable tbody tr') 323 self.wait_until_visible('#projectstable tbody tr', poll=3)
321 324
322 show_rows = self.driver.find_elements( 325 show_rows = self.driver.find_elements(
323 By.XPATH, 326 By.XPATH,
diff --git a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
index 1afa4a4d32..b713f30039 100644
--- a/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
@@ -7,6 +7,7 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10from django.urls import reverse 11from django.urls import reverse
11from django.utils import timezone 12from django.utils import timezone
12 13
@@ -21,7 +22,8 @@ class TestBuildDashboardPage(SeleniumTestCase):
21 """ Tests for the build dashboard /build/X """ 22 """ Tests for the build dashboard /build/X """
22 23
23 def setUp(self): 24 def setUp(self):
24 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/', 25 builldir = os.environ.get('BUILDDIR', './')
26 bbv = BitbakeVersion.objects.create(name='bbv1', giturl=f'{builldir}/',
25 branch='master', dirpath="") 27 branch='master', dirpath="")
26 release = Release.objects.create(name='release1', 28 release = Release.objects.create(name='release1',
27 bitbake_version=bbv) 29 bitbake_version=bbv)
diff --git a/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py b/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
index adea2edb0a..675825bd40 100644
--- a/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
+++ b/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
@@ -7,6 +7,7 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10from django.urls import reverse 11from django.urls import reverse
11from django.utils import timezone 12from django.utils import timezone
12 13
@@ -20,7 +21,8 @@ class TestBuildDashboardPageArtifacts(SeleniumTestCase):
20 """ Tests for artifacts on the build dashboard /build/X """ 21 """ Tests for artifacts on the build dashboard /build/X """
21 22
22 def setUp(self): 23 def setUp(self):
23 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/', 24 builldir = os.environ.get('BUILDDIR', './')
25 bbv = BitbakeVersion.objects.create(name='bbv1', giturl=f'{builldir}/',
24 branch='master', dirpath="") 26 branch='master', dirpath="")
25 release = Release.objects.create(name='release1', 27 release = Release.objects.create(name='release1',
26 bitbake_version=bbv) 28 bitbake_version=bbv)
diff --git a/bitbake/lib/toaster/tests/browser/test_landing_page.py b/bitbake/lib/toaster/tests/browser/test_landing_page.py
index ca0b2e631a..f6649a3d82 100644
--- a/bitbake/lib/toaster/tests/browser/test_landing_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_landing_page.py
@@ -14,6 +14,7 @@ from selenium.webdriver.common.by import By
14 14
15from orm.models import Layer, Layer_Version, Project, Build 15from orm.models import Layer, Layer_Version, Project, Build
16 16
17
17class TestLandingPage(SeleniumTestCase): 18class TestLandingPage(SeleniumTestCase):
18 """ Tests for redirects on the landing page """ 19 """ Tests for redirects on the landing page """
19 20
@@ -40,7 +41,7 @@ class TestLandingPage(SeleniumTestCase):
40 41
41 # check that the info sign is clickable 42 # check that the info sign is clickable
42 # and info modal is appearing when clicking on the info sign 43 # and info modal is appearing when clicking on the info sign
43 info_sign.click() # click on the info sign make attribute 'aria-describedby' visible 44 info_sign.click() # click on the info sign make attribute 'aria-describedby' visible
44 info_model_id = info_sign.get_attribute('aria-describedby') 45 info_model_id = info_sign.get_attribute('aria-describedby')
45 info_modal = self.find(f'#{info_model_id}') 46 info_modal = self.find(f'#{info_model_id}')
46 self.assertTrue(info_modal.is_displayed()) 47 self.assertTrue(info_modal.is_displayed())
@@ -55,7 +56,7 @@ class TestLandingPage(SeleniumTestCase):
55 self.assertTrue(documentation_link.is_displayed()) 56 self.assertTrue(documentation_link.is_displayed())
56 57
57 # check browser open new tab toaster manual when clicking on the documentation link 58 # check browser open new tab toaster manual when clicking on the documentation link
58 self.assertEqual(documentation_link.get_attribute('target') , '_blank') 59 self.assertEqual(documentation_link.get_attribute('target'), '_blank')
59 self.assertEqual( 60 self.assertEqual(
60 documentation_link.get_attribute('href'), 61 documentation_link.get_attribute('href'),
61 'http://docs.yoctoproject.org/toaster-manual/index.html#toaster-user-manual') 62 'http://docs.yoctoproject.org/toaster-manual/index.html#toaster-user-manual')
@@ -81,7 +82,8 @@ class TestLandingPage(SeleniumTestCase):
81 bitbake = jumbotron.find_element(By.LINK_TEXT, 'BitBake') 82 bitbake = jumbotron.find_element(By.LINK_TEXT, 'BitBake')
82 self.assertTrue(bitbake.is_displayed()) 83 self.assertTrue(bitbake.is_displayed())
83 bitbake.click() 84 bitbake.click()
84 self.assertTrue("docs.yoctoproject.org/bitbake.html" in self.driver.current_url) 85 self.assertTrue(
86 "docs.yoctoproject.org/bitbake.html" in self.driver.current_url)
85 87
86 def test_yoctoproject_jumbotron_link_visible_and_clickable(self): 88 def test_yoctoproject_jumbotron_link_visible_and_clickable(self):
87 """ Test Yocto Project link jumbotron is visible and clickable: """ 89 """ Test Yocto Project link jumbotron is visible and clickable: """
@@ -103,11 +105,12 @@ class TestLandingPage(SeleniumTestCase):
103 105
104 # check Big magenta button 106 # check Big magenta button
105 big_magenta_button = jumbotron.find_element(By.LINK_TEXT, 107 big_magenta_button = jumbotron.find_element(By.LINK_TEXT,
106 'Toaster is ready to capture your command line builds' 108 'Toaster is ready to capture your command line builds'
107 ) 109 )
108 self.assertTrue(big_magenta_button.is_displayed()) 110 self.assertTrue(big_magenta_button.is_displayed())
109 big_magenta_button.click() 111 big_magenta_button.click()
110 self.assertTrue("docs.yoctoproject.org/toaster-manual/setup-and-use.html#setting-up-and-using-toaster" in self.driver.current_url) 112 self.assertTrue(
113 "docs.yoctoproject.org/toaster-manual/setup-and-use.html#setting-up-and-using-toaster" in self.driver.current_url)
111 114
112 def test_link_create_new_project_in_jumbotron_visible_and_clickable(self): 115 def test_link_create_new_project_in_jumbotron_visible_and_clickable(self):
113 """ Test big blue button create new project jumbotron if visible and clickable """ 116 """ Test big blue button create new project jumbotron if visible and clickable """
@@ -120,8 +123,8 @@ class TestLandingPage(SeleniumTestCase):
120 123
121 # check Big Blue button 124 # check Big Blue button
122 big_blue_button = jumbotron.find_element(By.LINK_TEXT, 125 big_blue_button = jumbotron.find_element(By.LINK_TEXT,
123 'Create your first Toaster project to run manage builds' 126 'Create your first Toaster project to run manage builds'
124 ) 127 )
125 self.assertTrue(big_blue_button.is_displayed()) 128 self.assertTrue(big_blue_button.is_displayed())
126 big_blue_button.click() 129 big_blue_button.click()
127 self.assertTrue("toastergui/newproject/" in self.driver.current_url) 130 self.assertTrue("toastergui/newproject/" in self.driver.current_url)
@@ -132,10 +135,12 @@ class TestLandingPage(SeleniumTestCase):
132 jumbotron = self.find('.jumbotron') 135 jumbotron = self.find('.jumbotron')
133 136
134 # check Read the Toaster manual 137 # check Read the Toaster manual
135 toaster_manual = jumbotron.find_element(By.LINK_TEXT, 'Read the Toaster manual') 138 toaster_manual = jumbotron.find_element(
139 By.LINK_TEXT, 'Read the Toaster manual')
136 self.assertTrue(toaster_manual.is_displayed()) 140 self.assertTrue(toaster_manual.is_displayed())
137 toaster_manual.click() 141 toaster_manual.click()
138 self.assertTrue("https://docs.yoctoproject.org/toaster-manual/index.html#toaster-user-manual" in self.driver.current_url) 142 self.assertTrue(
143 "https://docs.yoctoproject.org/toaster-manual/index.html#toaster-user-manual" in self.driver.current_url)
139 144
140 def test_contrib_to_toaster_link_visible_and_clickable(self): 145 def test_contrib_to_toaster_link_visible_and_clickable(self):
141 """ Test Contribute to Toaster link jumbotron is visible and clickable: """ 146 """ Test Contribute to Toaster link jumbotron is visible and clickable: """
@@ -143,10 +148,12 @@ class TestLandingPage(SeleniumTestCase):
143 jumbotron = self.find('.jumbotron') 148 jumbotron = self.find('.jumbotron')
144 149
145 # check Contribute to Toaster 150 # check Contribute to Toaster
146 contribute_to_toaster = jumbotron.find_element(By.LINK_TEXT, 'Contribute to Toaster') 151 contribute_to_toaster = jumbotron.find_element(
152 By.LINK_TEXT, 'Contribute to Toaster')
147 self.assertTrue(contribute_to_toaster.is_displayed()) 153 self.assertTrue(contribute_to_toaster.is_displayed())
148 contribute_to_toaster.click() 154 contribute_to_toaster.click()
149 self.assertTrue("wiki.yoctoproject.org/wiki/contribute_to_toaster" in str(self.driver.current_url).lower()) 155 self.assertTrue(
156 "wiki.yoctoproject.org/wiki/contribute_to_toaster" in str(self.driver.current_url).lower())
150 157
151 def test_only_default_project(self): 158 def test_only_default_project(self):
152 """ 159 """
@@ -206,7 +213,7 @@ class TestLandingPage(SeleniumTestCase):
206 213
207 self.get(reverse('landing')) 214 self.get(reverse('landing'))
208 215
209 self.wait_until_visible("#latest-builds") 216 self.wait_until_visible("#latest-builds", poll=3)
210 elements = self.find_all('#allbuildstable') 217 elements = self.find_all('#allbuildstable')
211 self.assertEqual(len(elements), 1, 'should redirect to builds') 218 self.assertEqual(len(elements), 1, 'should redirect to builds')
212 content = self.get_page_source() 219 content = self.get_page_source()
diff --git a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
index 27cda0f2e7..367c6179c6 100644
--- a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
@@ -106,7 +106,7 @@ class TestLayerDetailsPage(SeleniumTestCase):
106 for save_btn in self.find_all(".change-btn"): 106 for save_btn in self.find_all(".change-btn"):
107 save_btn.click() 107 save_btn.click()
108 108
109 self.wait_until_visible("#save-changes-for-switch") 109 self.wait_until_visible("#save-changes-for-switch", poll=3)
110 btn_save_chg_for_switch = self.find("#save-changes-for-switch") 110 btn_save_chg_for_switch = self.find("#save-changes-for-switch")
111 btn_save_chg_for_switch.click() 111 btn_save_chg_for_switch.click()
112 self.wait_until_visible("#edit-layer-source") 112 self.wait_until_visible("#edit-layer-source")
@@ -137,7 +137,7 @@ class TestLayerDetailsPage(SeleniumTestCase):
137 new_dir = "/home/test/my-meta-dir" 137 new_dir = "/home/test/my-meta-dir"
138 dir_input.send_keys(new_dir) 138 dir_input.send_keys(new_dir)
139 139
140 self.wait_until_visible("#save-changes-for-switch") 140 self.wait_until_visible("#save-changes-for-switch", poll=3)
141 btn_save_chg_for_switch = self.find("#save-changes-for-switch") 141 btn_save_chg_for_switch = self.find("#save-changes-for-switch")
142 btn_save_chg_for_switch.click() 142 btn_save_chg_for_switch.click()
143 self.wait_until_visible("#edit-layer-source") 143 self.wait_until_visible("#edit-layer-source")
diff --git a/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py b/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
index c13d328e47..d7a4c34532 100644
--- a/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
+++ b/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
@@ -6,7 +6,6 @@
6# 6#
7# Copyright (C) 2013-2016 Intel Corporation 7# Copyright (C) 2013-2016 Intel Corporation
8# 8#
9import time
10from django.urls import reverse 9from django.urls import reverse
11from django.utils import timezone 10from django.utils import timezone
12from tests.browser.selenium_helpers import SeleniumTestCase 11from tests.browser.selenium_helpers import SeleniumTestCase
diff --git a/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py b/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
index f4d95b1acd..4ad22c7aa7 100644
--- a/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
@@ -45,10 +45,11 @@ class TestNewCustomImagePage(SeleniumTestCase):
45 ) 45 )
46 46
47 # add a fake image recipe to the layer that can be customised 47 # add a fake image recipe to the layer that can be customised
48 builldir = os.environ.get('BUILDDIR', './')
48 self.recipe = Recipe.objects.create( 49 self.recipe = Recipe.objects.create(
49 name='core-image-minimal', 50 name='core-image-minimal',
50 layer_version=layer_version, 51 layer_version=layer_version,
51 file_path='/tmp/core-image-minimal.bb', 52 file_path=f'{builldir}/core-image-minimal.bb',
52 is_image=True 53 is_image=True
53 ) 54 )
54 # create a tmp file for the recipe 55 # create a tmp file for the recipe
diff --git a/bitbake/lib/toaster/tests/browser/test_new_project_page.py b/bitbake/lib/toaster/tests/browser/test_new_project_page.py
index f4b2708f77..0c33c44f4a 100644
--- a/bitbake/lib/toaster/tests/browser/test_new_project_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_new_project_page.py
@@ -6,8 +6,6 @@
6# 6#
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9import time
10
11from django.urls import reverse 9from django.urls import reverse
12from tests.browser.selenium_helpers import SeleniumTestCase 10from tests.browser.selenium_helpers import SeleniumTestCase
13from selenium.webdriver.support.ui import Select 11from selenium.webdriver.support.ui import Select
@@ -54,13 +52,12 @@ class TestNewProjectPage(SeleniumTestCase):
54 select = Select(self.find('#projectversion')) 52 select = Select(self.find('#projectversion'))
55 select.select_by_value(str(self.release.pk)) 53 select.select_by_value(str(self.release.pk))
56 54
57 time.sleep(1)
58 self.click("#create-project-button") 55 self.click("#create-project-button")
59 time.sleep(2)
60 56
61 # We should get redirected to the new project's page with the 57 # We should get redirected to the new project's page with the
62 # notification at the top 58 # notification at the top
63 element = self.wait_until_visible('#project-created-notification') 59 element = self.wait_until_visible(
60 '#project-created-notification', poll=3)
64 61
65 self.assertTrue(project_name in element.text, 62 self.assertTrue(project_name in element.text,
66 "New project name not in new project notification") 63 "New project name not in new project notification")
@@ -91,9 +88,8 @@ class TestNewProjectPage(SeleniumTestCase):
91 radio.click() 88 radio.click()
92 89
93 self.click("#create-project-button") 90 self.click("#create-project-button")
94 time.sleep(2)
95 91
96 element = self.wait_until_visible('#hint-error-project-name') 92 element = self.wait_until_visible('#hint-error-project-name', poll=3)
97 93
98 self.assertTrue(("Project names must be unique" in element.text), 94 self.assertTrue(("Project names must be unique" in element.text),
99 "Did not find unique project name error message") 95 "Did not find unique project name error message")
@@ -105,7 +101,6 @@ class TestNewProjectPage(SeleniumTestCase):
105 except InvalidElementStateException: 101 except InvalidElementStateException:
106 pass 102 pass
107 103
108 time.sleep(2)
109 self.assertTrue( 104 self.assertTrue(
110 (Project.objects.filter(name=project_name).count() == 1), 105 (Project.objects.filter(name=project_name).count() == 1),
111 "New project not found in database") 106 "New project not found in database")
diff --git a/bitbake/lib/toaster/tests/browser/test_project_builds_page.py b/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
index 51717e72d4..0dba33b9c8 100644
--- a/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
@@ -7,6 +7,7 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10import re 11import re
11 12
12from django.urls import reverse 13from django.urls import reverse
@@ -22,7 +23,8 @@ class TestProjectBuildsPage(SeleniumTestCase):
22 CLI_BUILDS_PROJECT_NAME = 'command line builds' 23 CLI_BUILDS_PROJECT_NAME = 'command line builds'
23 24
24 def setUp(self): 25 def setUp(self):
25 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/', 26 builldir = os.environ.get('BUILDDIR', './')
27 bbv = BitbakeVersion.objects.create(name='bbv1', giturl=f'{builldir}/',
26 branch='master', dirpath='') 28 branch='master', dirpath='')
27 release = Release.objects.create(name='release1', 29 release = Release.objects.create(name='release1',
28 bitbake_version=bbv) 30 bitbake_version=bbv)
diff --git a/bitbake/lib/toaster/tests/browser/test_project_config_page.py b/bitbake/lib/toaster/tests/browser/test_project_config_page.py
index 7b21460e83..b9de541efa 100644
--- a/bitbake/lib/toaster/tests/browser/test_project_config_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_project_config_page.py
@@ -7,6 +7,7 @@
7# SPDX-License-Identifier: GPL-2.0-only 7# SPDX-License-Identifier: GPL-2.0-only
8# 8#
9 9
10import os
10from django.urls import reverse 11from django.urls import reverse
11from tests.browser.selenium_helpers import SeleniumTestCase 12from tests.browser.selenium_helpers import SeleniumTestCase
12 13
@@ -22,7 +23,8 @@ class TestProjectConfigsPage(SeleniumTestCase):
22 'any of these characters' 23 'any of these characters'
23 24
24 def setUp(self): 25 def setUp(self):
25 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/', 26 builldir = os.environ.get('BUILDDIR', './')
27 bbv = BitbakeVersion.objects.create(name='bbv1', giturl=f'{builldir}/',
26 branch='master', dirpath='') 28 branch='master', dirpath='')
27 release = Release.objects.create(name='release1', 29 release = Release.objects.create(name='release1',
28 bitbake_version=bbv) 30 bitbake_version=bbv)
diff --git a/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py b/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
index e00c30a8a3..691aca1ef0 100644
--- a/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
+++ b/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
@@ -8,6 +8,7 @@
8# 8#
9 9
10from datetime import datetime 10from datetime import datetime
11import os
11 12
12from django.urls import reverse 13from django.urls import reverse
13from django.utils import timezone 14from django.utils import timezone
@@ -59,7 +60,8 @@ class TestToasterTableUI(SeleniumTestCase):
59 later = now + timezone.timedelta(hours=1) 60 later = now + timezone.timedelta(hours=1)
60 even_later = later + timezone.timedelta(hours=1) 61 even_later = later + timezone.timedelta(hours=1)
61 62
62 bbv = BitbakeVersion.objects.create(name='test bbv', giturl='/tmp/', 63 builldir = os.environ.get('BUILDDIR', './')
64 bbv = BitbakeVersion.objects.create(name='test bbv', giturl=f'{builldir}/',
63 branch='master', dirpath='') 65 branch='master', dirpath='')
64 release = Release.objects.create(name='test release', 66 release = Release.objects.create(name='test release',
65 branch_name='master', 67 branch_name='master',
diff --git a/bitbake/lib/toaster/tests/views/test_views.py b/bitbake/lib/toaster/tests/views/test_views.py
index d9f3eb868b..e1adfcf86a 100644
--- a/bitbake/lib/toaster/tests/views/test_views.py
+++ b/bitbake/lib/toaster/tests/views/test_views.py
@@ -9,6 +9,7 @@
9 9
10"""Test cases for Toaster GUI and ReST.""" 10"""Test cases for Toaster GUI and ReST."""
11 11
12import os
12import pytest 13import pytest
13from django.test import TestCase 14from django.test import TestCase
14from django.test.client import RequestFactory 15from django.test.client import RequestFactory
@@ -39,6 +40,7 @@ class ViewTests(TestCase):
39 """Tests to verify view APIs.""" 40 """Tests to verify view APIs."""
40 41
41 fixtures = ['toastergui-unittest-data'] 42 fixtures = ['toastergui-unittest-data']
43 builldir = os.environ.get('BUILDDIR')
42 44
43 def setUp(self): 45 def setUp(self):
44 46
@@ -46,7 +48,7 @@ class ViewTests(TestCase):
46 48
47 self.recipe1 = Recipe.objects.get(pk=2) 49 self.recipe1 = Recipe.objects.get(pk=2)
48 # create a file and to recipe1 file_path 50 # create a file and to recipe1 file_path
49 file_path = f"/tmp/{self.recipe1.name.strip().replace(' ', '-')}.bb" 51 file_path = f"{self.builldir}/{self.recipe1.name.strip().replace(' ', '-')}.bb"
50 with open(file_path, 'w') as f: 52 with open(file_path, 'w') as f:
51 f.write('foo') 53 f.write('foo')
52 self.recipe1.file_path = file_path 54 self.recipe1.file_path = file_path
@@ -240,7 +242,7 @@ class ViewTests(TestCase):
240 recipe = CustomImageRecipe.objects.create( 242 recipe = CustomImageRecipe.objects.create(
241 name=name, project=self.project, 243 name=name, project=self.project,
242 base_recipe=self.recipe1, 244 base_recipe=self.recipe1,
243 file_path="/tmp/testing", 245 file_path=f"{self.builldir}/testing",
244 layer_version=self.customr.layer_version) 246 layer_version=self.customr.layer_version)
245 url = reverse('xhr_customrecipe_id', args=(recipe.id,)) 247 url = reverse('xhr_customrecipe_id', args=(recipe.id,))
246 response = self.client.delete(url) 248 response = self.client.delete(url)
@@ -311,7 +313,7 @@ class ViewTests(TestCase):
311 """Download the recipe file generated for the custom image""" 313 """Download the recipe file generated for the custom image"""
312 314
313 # Create a dummy recipe file for the custom image generation to read 315 # Create a dummy recipe file for the custom image generation to read
314 open("/tmp/a_recipe.bb", 'a').close() 316 open(f"{self.builldir}/a_recipe.bb", 'a').close()
315 response = self.client.get(reverse('customrecipedownload', 317 response = self.client.get(reverse('customrecipedownload',
316 args=(self.project.id, 318 args=(self.project.id,
317 self.customr.id))) 319 self.customr.id)))