summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/tests
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-03-31 19:55:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-01 07:14:58 +0100
commit961cd90375630773f376328f8921804438e0f033 (patch)
treec468c35dac8565bed6a684f3b182ba1c75e5eb8d /bitbake/lib/toaster/tests
parentf859a3d40e91e64d4b5292cefd880075a27ddaf9 (diff)
downloadpoky-961cd90375630773f376328f8921804438e0f033.tar.gz
bitbake: toaster: tests Migrate all builds page and project page tests to Selenium
(Bitbake rev: 4fda6be831d10e6d266b11975a0e9a35a7f35a77) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Michael Wood <michael.g.wood@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.py143
-rw-r--r--bitbake/lib/toaster/tests/browser/test_project_page.py59
2 files changed, 202 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
new file mode 100644
index 0000000000..e4223f482a
--- /dev/null
+++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
@@ -0,0 +1,143 @@
1#! /usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# BitBake Toaster Implementation
6#
7# Copyright (C) 2013-2016 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22import re
23
24from django.core.urlresolvers import reverse
25from django.utils import timezone
26from tests.browser.selenium_helpers import SeleniumTestCase
27
28from orm.models import BitbakeVersion, Release, Project, Build, Target
29
30class TestAllBuildsPage(SeleniumTestCase):
31 """ Tests for all builds page /builds/ """
32
33 PROJECT_NAME = 'test project'
34 CLI_BUILDS_PROJECT_NAME = 'command line builds'
35
36 def setUp(self):
37 bbv = BitbakeVersion.objects.create(name='bbv1', giturl='/tmp/',
38 branch='master', dirpath='')
39 release = Release.objects.create(name='release1',
40 bitbake_version=bbv)
41 self.project1 = Project.objects.create_project(name=self.PROJECT_NAME,
42 release=release)
43 self.default_project = Project.objects.create_project(
44 name=self.CLI_BUILDS_PROJECT_NAME,
45 release=release
46 )
47 self.default_project.is_default = True
48 self.default_project.save()
49
50 # parameters for builds to associate with the projects
51 now = timezone.now()
52
53 self.project1_build_success = {
54 'project': self.project1,
55 'started_on': now,
56 'completed_on': now,
57 'outcome': Build.SUCCEEDED
58 }
59
60 self.default_project_build_success = {
61 'project': self.default_project,
62 'started_on': now,
63 'completed_on': now,
64 'outcome': Build.SUCCEEDED
65 }
66
67 def test_show_tasks_with_suffix(self):
68 """ Task should be shown as suffix on build name """
69 build = Build.objects.create(**self.project1_build_success)
70 target = 'bash'
71 task = 'clean'
72 Target.objects.create(build=build, target=target, task=task)
73
74 url = reverse('all-builds')
75 self.get(url)
76 self.wait_until_present('td[class="target"]')
77
78 cell = self.find('td[class="target"]')
79 content = cell.get_attribute('innerHTML')
80 expected_text = '%s:%s' % (target, task)
81
82 self.assertTrue(re.search(expected_text, content),
83 '"target" cell should contain text %s' % expected_text)
84
85 def test_rebuild_buttons(self):
86 """
87 Test 'Rebuild' buttons in recent builds section
88
89 'Rebuild' button should not be shown for command-line builds,
90 but should be shown for other builds
91 """
92 build1 = Build.objects.create(**self.project1_build_success)
93 default_build = Build.objects.create(**self.default_project_build_success)
94
95 url = reverse('all-builds')
96 self.get(url)
97
98 # shouldn't see a run again button for command-line builds
99 selector = 'div[data-latest-build-result="%s"] button' % default_build.id
100 run_again_button = self.find_all(selector)
101 self.assertEqual(len(run_again_button), 0,
102 'should not see a run again button for cli builds')
103
104 # should see a run again button for non-command-line builds
105 selector = 'div[data-latest-build-result="%s"] button' % build1.id
106 run_again_button = self.find_all(selector)
107 self.assertEqual(len(run_again_button), 1,
108 'should see a run again button for non-cli builds')
109
110 def test_tooltips_on_project_name(self):
111 """
112 Test tooltips shown next to project name in the main table
113
114 A tooltip should be present next to the command line
115 builds project name in the all builds page, but not for
116 other projects
117 """
118 Build.objects.create(**self.project1_build_success)
119 Build.objects.create(**self.default_project_build_success)
120
121 url = reverse('all-builds')
122 self.get(url)
123
124 # get the project name cells from the table
125 cells = self.find_all('#allbuildstable td[class="project"]')
126
127 selector = 'i.get-help'
128
129 for cell in cells:
130 content = cell.get_attribute('innerHTML')
131 help_icons = cell.find_elements_by_css_selector(selector)
132
133 if re.search(self.PROJECT_NAME, content):
134 # no help icon next to non-cli project name
135 msg = 'should not be a help icon for non-cli builds name'
136 self.assertEqual(len(help_icons), 0, msg)
137 elif re.search(self.CLI_BUILDS_PROJECT_NAME, content):
138 # help icon next to cli project name
139 msg = 'should be a help icon for cli builds name'
140 self.assertEqual(len(help_icons), 1, msg)
141 else:
142 msg = 'found unexpected project name cell in all builds table'
143 self.fail(msg)
diff --git a/bitbake/lib/toaster/tests/browser/test_project_page.py b/bitbake/lib/toaster/tests/browser/test_project_page.py
new file mode 100644
index 0000000000..786bef1c6e
--- /dev/null
+++ b/bitbake/lib/toaster/tests/browser/test_project_page.py
@@ -0,0 +1,59 @@
1#! /usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# BitBake Toaster Implementation
6#
7# Copyright (C) 2013-2016 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22from django.core.urlresolvers import reverse
23from django.utils import timezone
24from tests.browser.selenium_helpers import SeleniumTestCase
25
26from orm.models import Build, Project
27
28class TestProjectPage(SeleniumTestCase):
29 """ Test project data at /project/X/ is displayed correctly """
30
31 CLI_BUILDS_PROJECT_NAME = 'Command line builds'
32
33 def test_cli_builds_in_progress(self):
34 """
35 In progress builds should not cause an error to be thrown
36 when navigating to "command line builds" project page;
37 see https://bugzilla.yoctoproject.org/show_bug.cgi?id=8277
38 """
39
40 # add the "command line builds" default project; this mirrors what
41 # we do with get_or_create_default_project()
42 default_project = Project.objects.create_project(self.CLI_BUILDS_PROJECT_NAME, None)
43 default_project.is_default = True
44 default_project.save()
45
46 # add an "in progress" build for the default project
47 now = timezone.now()
48 Build.objects.create(project=default_project,
49 started_on=now,
50 completed_on=now,
51 outcome=Build.IN_PROGRESS)
52
53 # navigate to the project page for the default project
54 url = reverse("project", args=(default_project.id,))
55 self.get(url)
56
57 # check that we get a project page with the correct heading
58 project_name = self.find('#project-name').text.strip()
59 self.assertEqual(project_name, self.CLI_BUILDS_PROJECT_NAME)