summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/tests.py
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-03-31 19:55:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-01 07:14:59 +0100
commit5b848fa7276dea302f392ac76f009c9353060166 (patch)
tree406b7a89142465e3e9bf607624be92af16cdefd6 /bitbake/lib/toaster/toastergui/tests.py
parentf2a38ea4a1b2fbc9ed14d54c9fc6f401b05d7715 (diff)
downloadpoky-5b848fa7276dea302f392ac76f009c9353060166.tar.gz
bitbake: toaster: tests Migrate all projects page tests to Selenium
(Bitbake rev: 0e5f45d68e423f8462937879eed3253db31b2bb5) 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/toastergui/tests.py')
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py197
1 files changed, 0 insertions, 197 deletions
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):
493 "Changed page on table %s but first row is the " 493 "Changed page on table %s but first row is the "
494 "same as the previous page" % name) 494 "same as the previous page" % name)
495 495
496
497class LandingPageTests(TestCase): 496class LandingPageTests(TestCase):
498 """ Tests for redirects on the landing page """ 497 """ Tests for redirects on the landing page """
499 # disable bogus pylint message error: 498 # disable bogus pylint message error:
@@ -568,202 +567,6 @@ class LandingPageTests(TestCase):
568 self.assertTrue('/builds' in response.url, 567 self.assertTrue('/builds' in response.url,
569 'should redirect to builds') 568 'should redirect to builds')
570 569
571class AllProjectsPageTests(TestCase):
572 """ Tests for projects page /projects/ """
573
574 MACHINE_NAME = 'delorean'
575
576 def setUp(self):
577 """ Add default project manually """
578 project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None)
579 self.default_project = project
580 self.default_project.is_default = True
581 self.default_project.save()
582
583 # this project is only set for some of the tests
584 self.project = None
585
586 self.release = None
587
588 def _add_build_to_default_project(self):
589 """ Add a build to the default project (not used in all tests) """
590 now = timezone.now()
591 build = Build.objects.create(project=self.default_project,
592 started_on=now,
593 completed_on=now)
594 build.save()
595
596 def _add_non_default_project(self):
597 """ Add another project """
598 bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/",
599 branch="master", dirpath="")
600 self.release = Release.objects.create(name="test release",
601 branch_name="master",
602 bitbake_version=bbv)
603 self.project = Project.objects.create_project(PROJECT_NAME, self.release)
604 self.project.is_default = False
605 self.project.save()
606
607 # fake the MACHINE variable
608 project_var = ProjectVariable.objects.create(project=self.project,
609 name='MACHINE',
610 value=self.MACHINE_NAME)
611 project_var.save()
612
613 def _get_row_for_project(self, data, project_id):
614 """ Get the object representing the table data for a project """
615 return [row for row in data['rows'] if row['id'] == project_id][0]
616
617 def test_default_project_hidden(self):
618 """ The default project should be hidden if it has no builds """
619 params = {"count": 10, "orderby": "updated:-", "page": 1}
620 response = self.client.get(reverse('all-projects'), params)
621
622 self.assertTrue(not('tr class="data"' in response.content),
623 'should be no project rows in the page')
624 self.assertTrue(not(CLI_BUILDS_PROJECT_NAME in response.content),
625 'default project "cli builds" should not be in page')
626
627 def test_default_project_has_build(self):
628 """ The default project should be shown if it has builds """
629 self._add_build_to_default_project()
630
631 params = {"count": 10, "orderby": "updated:-", "page": 1}
632
633 response = self.client.get(
634 reverse('all-projects'),
635 {'format': 'json'},
636 params
637 )
638
639 data = json.loads(response.content)
640
641 # find the row for the default project
642 default_project_row = self._get_row_for_project(data, self.default_project.id)
643
644 # check its name template has the correct text
645 self.assertEqual(default_project_row['name'], CLI_BUILDS_PROJECT_NAME,
646 'default project "cli builds" should be in page')
647
648 def test_default_project_release(self):
649 """
650 The release for the default project should display as
651 'Not applicable'
652 """
653 # need a build, otherwise project doesn't display at all
654 self._add_build_to_default_project()
655
656 # another project to test, which should show release
657 self._add_non_default_project()
658
659 response = self.client.get(
660 reverse('all-projects'),
661 {'format': 'json'},
662 follow=True
663 )
664
665 data = json.loads(response.content)
666
667 # used to find the correct span in the template output
668 attrs = {'data-project-field': 'release'}
669
670 # find the row for the default project
671 default_project_row = self._get_row_for_project(data, self.default_project.id)
672
673 # check the release text for the default project
674 soup = BeautifulSoup(default_project_row['static:release'])
675 text = soup.find('span', attrs=attrs).select('span.muted')[0].text
676 self.assertEqual(text, 'Not applicable',
677 'release should be not applicable for default project')
678
679 # find the row for the default project
680 other_project_row = self._get_row_for_project(data, self.project.id)
681
682 # check the link in the release cell for the other project
683 soup = BeautifulSoup(other_project_row['static:release'])
684 text = soup.find('span', attrs=attrs).select('a')[0].text.strip()
685 self.assertEqual(text, self.release.name,
686 'release name should be shown for non-default project')
687
688 def test_default_project_machine(self):
689 """
690 The machine for the default project should display as
691 'Not applicable'
692 """
693 # need a build, otherwise project doesn't display at all
694 self._add_build_to_default_project()
695
696 # another project to test, which should show machine
697 self._add_non_default_project()
698
699 response = self.client.get(
700 reverse('all-projects'),
701 {'format': 'json'},
702 follow=True
703 )
704
705 data = json.loads(response.content)
706
707 # used to find the correct span in the template output
708 attrs = {'data-project-field': 'machine'}
709
710 # find the row for the default project
711 default_project_row = self._get_row_for_project(data, self.default_project.id)
712
713 # check the machine cell for the default project
714 soup = BeautifulSoup(default_project_row['static:machine'])
715 text = soup.find('span', attrs=attrs).select('span.muted')[0].text.strip()
716 self.assertEqual(text, 'Not applicable',
717 'machine should be not applicable for default project')
718
719 # find the row for the default project
720 other_project_row = self._get_row_for_project(data, self.project.id)
721
722 # check the link in the machine cell for the other project
723 soup = BeautifulSoup(other_project_row['static:machine'])
724 text = soup.find('span', attrs=attrs).find('a').text.strip()
725 self.assertEqual(text, self.MACHINE_NAME,
726 'machine name should be shown for non-default project')
727
728 def test_project_page_links(self):
729 """
730 Test that links for the default project point to the builds
731 page /projects/X/builds for that project, and that links for
732 other projects point to their configuration pages /projects/X/
733 """
734
735 # need a build, otherwise project doesn't display at all
736 self._add_build_to_default_project()
737
738 # another project to test
739 self._add_non_default_project()
740
741 response = self.client.get(
742 reverse('all-projects'),
743 {'format': 'json'},
744 follow=True
745 )
746
747 data = json.loads(response.content)
748
749 # find the row for the default project
750 default_project_row = self._get_row_for_project(data, self.default_project.id)
751
752 # check the link on the name field
753 soup = BeautifulSoup(default_project_row['static:name'])
754 expected_url = reverse('projectbuilds', args=(self.default_project.id,))
755 self.assertEqual(soup.find('a')['href'], expected_url,
756 'link on default project name should point to builds')
757
758 # find the row for the other project
759 other_project_row = self._get_row_for_project(data, self.project.id)
760
761 # check the link for the other project
762 soup = BeautifulSoup(other_project_row['static:name'])
763 expected_url = reverse('project', args=(self.project.id,))
764 self.assertEqual(soup.find('a')['href'], expected_url,
765 'link on project name should point to configuration')
766
767class BuildDashboardTests(TestCase): 570class BuildDashboardTests(TestCase):
768 """ Tests for the build dashboard /build/X """ 571 """ Tests for the build dashboard /build/X """
769 572