From 5b848fa7276dea302f392ac76f009c9353060166 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Thu, 31 Mar 2016 19:55:46 +0100 Subject: bitbake: toaster: tests Migrate all projects page tests to Selenium (Bitbake rev: 0e5f45d68e423f8462937879eed3253db31b2bb5) Signed-off-by: Elliot Smith Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/tests.py | 197 -------------------------------- 1 file changed, 197 deletions(-) (limited to 'bitbake/lib/toaster/toastergui') diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 7192947326..6975ac1bfe 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -493,7 +493,6 @@ class ViewTests(TestCase): "Changed page on table %s but first row is the " "same as the previous page" % name) - class LandingPageTests(TestCase): """ Tests for redirects on the landing page """ # disable bogus pylint message error: @@ -568,202 +567,6 @@ class LandingPageTests(TestCase): self.assertTrue('/builds' in response.url, 'should redirect to builds') -class AllProjectsPageTests(TestCase): - """ Tests for projects page /projects/ """ - - MACHINE_NAME = 'delorean' - - def setUp(self): - """ Add default project manually """ - project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None) - self.default_project = project - self.default_project.is_default = True - self.default_project.save() - - # this project is only set for some of the tests - self.project = None - - self.release = None - - def _add_build_to_default_project(self): - """ Add a build to the default project (not used in all tests) """ - now = timezone.now() - build = Build.objects.create(project=self.default_project, - started_on=now, - completed_on=now) - build.save() - - def _add_non_default_project(self): - """ Add another project """ - bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/", - branch="master", dirpath="") - self.release = Release.objects.create(name="test release", - branch_name="master", - bitbake_version=bbv) - self.project = Project.objects.create_project(PROJECT_NAME, self.release) - self.project.is_default = False - self.project.save() - - # fake the MACHINE variable - project_var = ProjectVariable.objects.create(project=self.project, - name='MACHINE', - value=self.MACHINE_NAME) - project_var.save() - - def _get_row_for_project(self, data, project_id): - """ Get the object representing the table data for a project """ - return [row for row in data['rows'] if row['id'] == project_id][0] - - def test_default_project_hidden(self): - """ The default project should be hidden if it has no builds """ - params = {"count": 10, "orderby": "updated:-", "page": 1} - response = self.client.get(reverse('all-projects'), params) - - self.assertTrue(not('tr class="data"' in response.content), - 'should be no project rows in the page') - self.assertTrue(not(CLI_BUILDS_PROJECT_NAME in response.content), - 'default project "cli builds" should not be in page') - - def test_default_project_has_build(self): - """ The default project should be shown if it has builds """ - self._add_build_to_default_project() - - params = {"count": 10, "orderby": "updated:-", "page": 1} - - response = self.client.get( - reverse('all-projects'), - {'format': 'json'}, - params - ) - - data = json.loads(response.content) - - # find the row for the default project - default_project_row = self._get_row_for_project(data, self.default_project.id) - - # check its name template has the correct text - self.assertEqual(default_project_row['name'], CLI_BUILDS_PROJECT_NAME, - 'default project "cli builds" should be in page') - - def test_default_project_release(self): - """ - The release for the default project should display as - 'Not applicable' - """ - # need a build, otherwise project doesn't display at all - self._add_build_to_default_project() - - # another project to test, which should show release - self._add_non_default_project() - - response = self.client.get( - reverse('all-projects'), - {'format': 'json'}, - follow=True - ) - - data = json.loads(response.content) - - # used to find the correct span in the template output - attrs = {'data-project-field': 'release'} - - # find the row for the default project - default_project_row = self._get_row_for_project(data, self.default_project.id) - - # check the release text for the default project - soup = BeautifulSoup(default_project_row['static:release']) - text = soup.find('span', attrs=attrs).select('span.muted')[0].text - self.assertEqual(text, 'Not applicable', - 'release should be not applicable for default project') - - # find the row for the default project - other_project_row = self._get_row_for_project(data, self.project.id) - - # check the link in the release cell for the other project - soup = BeautifulSoup(other_project_row['static:release']) - text = soup.find('span', attrs=attrs).select('a')[0].text.strip() - self.assertEqual(text, self.release.name, - 'release name should be shown for non-default project') - - def test_default_project_machine(self): - """ - The machine for the default project should display as - 'Not applicable' - """ - # need a build, otherwise project doesn't display at all - self._add_build_to_default_project() - - # another project to test, which should show machine - self._add_non_default_project() - - response = self.client.get( - reverse('all-projects'), - {'format': 'json'}, - follow=True - ) - - data = json.loads(response.content) - - # used to find the correct span in the template output - attrs = {'data-project-field': 'machine'} - - # find the row for the default project - default_project_row = self._get_row_for_project(data, self.default_project.id) - - # check the machine cell for the default project - soup = BeautifulSoup(default_project_row['static:machine']) - text = soup.find('span', attrs=attrs).select('span.muted')[0].text.strip() - self.assertEqual(text, 'Not applicable', - 'machine should be not applicable for default project') - - # find the row for the default project - other_project_row = self._get_row_for_project(data, self.project.id) - - # check the link in the machine cell for the other project - soup = BeautifulSoup(other_project_row['static:machine']) - text = soup.find('span', attrs=attrs).find('a').text.strip() - self.assertEqual(text, self.MACHINE_NAME, - 'machine name should be shown for non-default project') - - def test_project_page_links(self): - """ - Test that links for the default project point to the builds - page /projects/X/builds for that project, and that links for - other projects point to their configuration pages /projects/X/ - """ - - # need a build, otherwise project doesn't display at all - self._add_build_to_default_project() - - # another project to test - self._add_non_default_project() - - response = self.client.get( - reverse('all-projects'), - {'format': 'json'}, - follow=True - ) - - data = json.loads(response.content) - - # find the row for the default project - default_project_row = self._get_row_for_project(data, self.default_project.id) - - # check the link on the name field - soup = BeautifulSoup(default_project_row['static:name']) - expected_url = reverse('projectbuilds', args=(self.default_project.id,)) - self.assertEqual(soup.find('a')['href'], expected_url, - 'link on default project name should point to builds') - - # find the row for the other project - other_project_row = self._get_row_for_project(data, self.project.id) - - # check the link for the other project - soup = BeautifulSoup(other_project_row['static:name']) - expected_url = reverse('project', args=(self.project.id,)) - self.assertEqual(soup.find('a')['href'], expected_url, - 'link on project name should point to configuration') - class BuildDashboardTests(TestCase): """ Tests for the build dashboard /build/X """ -- cgit v1.2.3-54-g00ecf