diff options
author | Elliot Smith <elliot.smith@intel.com> | 2016-04-26 16:32:11 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-11 00:09:26 +0100 |
commit | 504a85822e240bef868de54bc55edf265ba87510 (patch) | |
tree | f62d1e1f4a1767bcb13fb3343dcc2ae228d7ba5a /bitbake/lib/toaster/tests | |
parent | 2d80b902b804bc5927afbec2ad215f8959d0f581 (diff) | |
download | poky-504a85822e240bef868de54bc55edf265ba87510.tar.gz |
bitbake: toaster-tests: add tests for build time links in the all builds page
When a build fails, it shouldn't have links on its build time in the
recent builds area or in the all builds table.
[YOCTO #8443]
(Bitbake rev: 3d7b247512eb01607741f5f6ce7cb01d241e49e7)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/test_all_builds_page.py | 89 |
1 files changed, 89 insertions, 0 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 521a280de8..b86f29bdd4 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py | |||
@@ -58,6 +58,13 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
58 | 'outcome': Build.SUCCEEDED | 58 | 'outcome': Build.SUCCEEDED |
59 | } | 59 | } |
60 | 60 | ||
61 | self.project1_build_failure = { | ||
62 | 'project': self.project1, | ||
63 | 'started_on': now, | ||
64 | 'completed_on': now, | ||
65 | 'outcome': Build.FAILED | ||
66 | } | ||
67 | |||
61 | self.default_project_build_success = { | 68 | self.default_project_build_success = { |
62 | 'project': self.default_project, | 69 | 'project': self.default_project, |
63 | 'started_on': now, | 70 | 'started_on': now, |
@@ -65,6 +72,46 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
65 | 'outcome': Build.SUCCEEDED | 72 | 'outcome': Build.SUCCEEDED |
66 | } | 73 | } |
67 | 74 | ||
75 | def _get_build_time_element(self, build): | ||
76 | """ | ||
77 | Return the HTML element containing the build time for a build | ||
78 | in the recent builds area | ||
79 | """ | ||
80 | selector = 'div[data-latest-build-result="%s"] ' \ | ||
81 | '[data-role="data-recent-build-buildtime-field"]' % build.id | ||
82 | |||
83 | # because this loads via Ajax, wait for it to be visible | ||
84 | self.wait_until_present(selector) | ||
85 | |||
86 | build_time_spans = self.find_all(selector) | ||
87 | |||
88 | self.assertEqual(len(build_time_spans), 1) | ||
89 | |||
90 | return build_time_spans[0] | ||
91 | |||
92 | def _get_row_for_build(self, build): | ||
93 | """ Get the table row for the build from the all builds table """ | ||
94 | self.wait_until_present('#allbuildstable') | ||
95 | |||
96 | rows = self.find_all('#allbuildstable tr') | ||
97 | |||
98 | # look for the row with a download link on the recipe which matches the | ||
99 | # build ID | ||
100 | url = reverse('builddashboard', args=(build.id,)) | ||
101 | selector = 'td.target a[href="%s"]' % url | ||
102 | |||
103 | found_row = None | ||
104 | for row in rows: | ||
105 | |||
106 | outcome_links = row.find_elements_by_css_selector(selector) | ||
107 | if len(outcome_links) == 1: | ||
108 | found_row = row | ||
109 | break | ||
110 | |||
111 | self.assertNotEqual(found_row, None) | ||
112 | |||
113 | return found_row | ||
114 | |||
68 | def test_show_tasks_with_suffix(self): | 115 | def test_show_tasks_with_suffix(self): |
69 | """ Task should be shown as suffix on build name """ | 116 | """ Task should be shown as suffix on build name """ |
70 | build = Build.objects.create(**self.project1_build_success) | 117 | build = Build.objects.create(**self.project1_build_success) |
@@ -142,3 +189,45 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
142 | else: | 189 | else: |
143 | msg = 'found unexpected project name cell in all builds table' | 190 | msg = 'found unexpected project name cell in all builds table' |
144 | self.fail(msg) | 191 | self.fail(msg) |
192 | |||
193 | def test_builds_time_links(self): | ||
194 | """ | ||
195 | Successful builds should have links on the time column and in the | ||
196 | recent builds area; failed builds should not have links on the time column, | ||
197 | or in the recent builds area | ||
198 | """ | ||
199 | build1 = Build.objects.create(**self.project1_build_success) | ||
200 | build2 = Build.objects.create(**self.project1_build_failure) | ||
201 | |||
202 | # add some targets to these builds so they have recipe links | ||
203 | # (and so we can find the row in the ToasterTable corresponding to | ||
204 | # a particular build) | ||
205 | Target.objects.create(build=build1, target='foo') | ||
206 | Target.objects.create(build=build2, target='bar') | ||
207 | |||
208 | url = reverse('all-builds') | ||
209 | self.get(url) | ||
210 | |||
211 | # test recent builds area for successful build | ||
212 | element = self._get_build_time_element(build1) | ||
213 | links = element.find_elements_by_css_selector('a') | ||
214 | msg = 'should be a link on the build time for a successful recent build' | ||
215 | self.assertEquals(len(links), 1, msg) | ||
216 | |||
217 | # test recent builds area for failed build | ||
218 | element = self._get_build_time_element(build2) | ||
219 | links = element.find_elements_by_css_selector('a') | ||
220 | msg = 'should not be a link on the build time for a failed recent build' | ||
221 | self.assertEquals(len(links), 0, msg) | ||
222 | |||
223 | # test the time column for successful build | ||
224 | build1_row = self._get_row_for_build(build1) | ||
225 | links = build1_row.find_elements_by_css_selector('td.time a') | ||
226 | msg = 'should be a link on the build time for a successful build' | ||
227 | self.assertEquals(len(links), 1, msg) | ||
228 | |||
229 | # test the time column for failed build | ||
230 | build2_row = self._get_row_for_build(build2) | ||
231 | links = build2_row.find_elements_by_css_selector('td.time a') | ||
232 | msg = 'should not be a link on the build time for a failed build' | ||
233 | self.assertEquals(len(links), 0, msg) | ||