From 961cd90375630773f376328f8921804438e0f033 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Thu, 31 Mar 2016 19:55:44 +0100 Subject: bitbake: toaster: tests Migrate all builds page and project page tests to Selenium (Bitbake rev: 4fda6be831d10e6d266b11975a0e9a35a7f35a77) Signed-off-by: Elliot Smith Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/tests.py | 140 -------------------------------- 1 file changed, 140 deletions(-) (limited to 'bitbake/lib/toaster/toastergui') diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 6b05916f32..78b7c04255 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -897,146 +897,6 @@ class ProjectBuildsPageTests(TestCase): self.assertEqual(len(tabs), 1, 'should be a top bar shown for non-command-line builds') -class AllBuildsPageTests(TestCase): - """ Tests for all builds page /builds/ """ - - def setUp(self): - bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/", - branch="master", dirpath="") - release = Release.objects.create(name="release1", - bitbake_version=bbv) - self.project1 = Project.objects.create_project(name=PROJECT_NAME, - release=release) - self.default_project = Project.objects.create_project( - name=CLI_BUILDS_PROJECT_NAME, - release=release - ) - self.default_project.is_default = True - self.default_project.save() - - # parameters for builds to associate with the projects - now = timezone.now() - - self.project1_build_success = { - "project": self.project1, - "started_on": now, - "completed_on": now, - "outcome": Build.SUCCEEDED - } - - self.default_project_build_success = { - "project": self.default_project, - "started_on": now, - "completed_on": now, - "outcome": Build.SUCCEEDED - } - - def _get_row_for_build(self, data, build_id): - """ Get the object representing the table data for a project """ - return [row for row in data['rows'] - if row['id'] == build_id][0] - - def test_show_tasks_in_allbuilds(self): - """ Task should be shown as suffix on build name """ - build = Build.objects.create(**self.project1_build_success) - Target.objects.create(build=build, target='bash', task='clean') - - url = reverse('all-builds') - response = self.client.get(url, {'format': 'json'}, follow=True) - data = json.loads(response.content) - cell = data['rows'][0]['static:target'] - - result = re.findall('bash:clean', cell, re.MULTILINE) - self.assertEqual(len(result), 1) - - def test_run_again(self): - """ - "Rebuild" button should not be shown for command-line builds, - but should be shown for other builds - """ - build1 = Build.objects.create(**self.project1_build_success) - default_build = Build.objects.create(**self.default_project_build_success) - url = reverse('all-builds') - response = self.client.get(url, follow=True) - soup = BeautifulSoup(response.content) - - # shouldn't see a run again button for command-line builds - attrs = {'data-latest-build-result': default_build.id} - result = soup.find('div', attrs=attrs) - run_again_button = result.select('button') - self.assertEqual(len(run_again_button), 0) - - # should see a run again button for non-command-line builds - attrs = {'data-latest-build-result': build1.id} - result = soup.find('div', attrs=attrs) - run_again_button = result.select('button') - self.assertEqual(len(run_again_button), 1) - - def test_tooltips_on_project_name(self): - """ - A tooltip should be present next to the command line - builds project name in the all builds page, but not for - other projects - """ - build1 = Build.objects.create(**self.project1_build_success) - default_build = Build.objects.create(**self.default_project_build_success) - - url = reverse('all-builds') - response = self.client.get(url, {'format': 'json'}, follow=True) - data = json.loads(response.content) - - # get the data row for the non-command-line builds project - other_project_row = self._get_row_for_build(data, build1.id) - - # make sure there is some HTML - soup = BeautifulSoup(other_project_row['static:project']) - self.assertEqual(len(soup.select('a')), 1, - 'should be a project name link') - - # no help icon on non-default project name - icons = soup.select('i.get-help') - self.assertEqual(len(icons), 0, - 'should not be a help icon for non-cli builds name') - - # get the data row for the command-line builds project - default_project_row = self._get_row_for_build(data, default_build.id) - - # help icon on default project name - soup = BeautifulSoup(default_project_row['static:project']) - icons = soup.select('i.get-help') - self.assertEqual(len(icons), 1, - 'should be a help icon for cli builds name') - -class ProjectPageTests(TestCase): - """ Test project data at /project/X/ is displayed correctly """ - CLI_BUILDS_PROJECT_NAME = 'Command line builds' - - def test_command_line_builds_in_progress(self): - """ - In progress builds should not cause an error to be thrown - when navigating to "command line builds" project page; - see https://bugzilla.yoctoproject.org/show_bug.cgi?id=8277 - """ - - # add the "command line builds" default project; this mirrors what - # we do in migration 0026_set_default_project.py - default_project = Project.objects.create_project(self.CLI_BUILDS_PROJECT_NAME, None) - default_project.is_default = True - default_project.save() - - # add an "in progress" build for the default project - now = timezone.now() - build = Build.objects.create(project=default_project, - started_on=now, - completed_on=now, - outcome=Build.IN_PROGRESS) - - # navigate to the project page for the default project - url = reverse("project", args=(default_project.id,)) - response = self.client.get(url, follow=True) - - self.assertEqual(response.status_code, 200) - class BuildDashboardTests(TestCase): """ Tests for the build dashboard /build/X """ -- cgit v1.2.3-54-g00ecf