summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-03-31 19:55:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-01 07:14:59 +0100
commit7dcb4c41272e8f611eabea991fa30df79b9e48e3 (patch)
tree6574ec36d7befef5a981cd9a7868f668d5a9bbdb
parent5b848fa7276dea302f392ac76f009c9353060166 (diff)
downloadpoky-7dcb4c41272e8f611eabea991fa30df79b9e48e3.tar.gz
bitbake: toaster: tests Migrate landing page tests to Selenium
(Bitbake rev: 20ce1e1b39a9b602eb51ca0ba3954ea3e999c874) 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>
-rw-r--r--bitbake/lib/toaster/tests/browser/test_landing_page.py108
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py74
2 files changed, 108 insertions, 74 deletions
diff --git a/bitbake/lib/toaster/tests/browser/test_landing_page.py b/bitbake/lib/toaster/tests/browser/test_landing_page.py
new file mode 100644
index 0000000000..4d4cd660fb
--- /dev/null
+++ b/bitbake/lib/toaster/tests/browser/test_landing_page.py
@@ -0,0 +1,108 @@
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 Project, Build
27
28class TestLandingPage(SeleniumTestCase):
29 """ Tests for redirects on the landing page """
30
31 PROJECT_NAME = 'test project'
32 LANDING_PAGE_TITLE = 'This is Toaster'
33 CLI_BUILDS_PROJECT_NAME = 'command line builds'
34
35 def setUp(self):
36 """ Add default project manually """
37 self.project = Project.objects.create_project(
38 self.CLI_BUILDS_PROJECT_NAME,
39 None
40 )
41 self.project.is_default = True
42 self.project.save()
43
44 def test_only_default_project(self):
45 """
46 No projects except default
47 => should see the landing page
48 """
49 self.get(reverse('landing'))
50 self.assertTrue(self.LANDING_PAGE_TITLE in self.get_page_source())
51
52 def test_default_project_has_build(self):
53 """
54 Default project has a build, no other projects
55 => should see the builds page
56 """
57 now = timezone.now()
58 build = Build.objects.create(project=self.project,
59 started_on=now,
60 completed_on=now)
61 build.save()
62
63 self.get(reverse('landing'))
64
65 elements = self.find_all('#allbuildstable')
66 self.assertEqual(len(elements), 1, 'should redirect to builds')
67 content = self.get_page_source()
68 self.assertFalse(self.PROJECT_NAME in content,
69 'should not show builds for project %s' % self.PROJECT_NAME)
70 self.assertTrue(self.CLI_BUILDS_PROJECT_NAME in content,
71 'should show builds for cli project')
72
73 def test_user_project_exists(self):
74 """
75 User has added a project (without builds)
76 => should see the projects page
77 """
78 user_project = Project.objects.create_project('foo', None)
79 user_project.save()
80
81 self.get(reverse('landing'))
82
83 elements = self.find_all('#projectstable')
84 self.assertEqual(len(elements), 1, 'should redirect to projects')
85
86 def test_user_project_has_build(self):
87 """
88 User has added a project (with builds), command line builds doesn't
89 => should see the builds page
90 """
91 user_project = Project.objects.create_project(self.PROJECT_NAME, None)
92 user_project.save()
93
94 now = timezone.now()
95 build = Build.objects.create(project=user_project,
96 started_on=now,
97 completed_on=now)
98 build.save()
99
100 self.get(reverse('landing'))
101
102 elements = self.find_all('#allbuildstable')
103 self.assertEqual(len(elements), 1, 'should redirect to builds')
104 content = self.get_page_source()
105 self.assertTrue(self.PROJECT_NAME in content,
106 'should show builds for project %s' % self.PROJECT_NAME)
107 self.assertFalse(self.CLI_BUILDS_PROJECT_NAME in content,
108 'should not show builds for cli project')
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 6975ac1bfe..eebd1b79ba 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -493,80 +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
496class LandingPageTests(TestCase):
497 """ Tests for redirects on the landing page """
498 # disable bogus pylint message error:
499 # "Instance of 'WSGIRequest' has no 'url' member (no-member)"
500 # (see https://github.com/landscapeio/pylint-django/issues/42)
501 # pylint: disable=E1103
502
503 LANDING_PAGE_TITLE = 'This is Toaster'
504
505 def setUp(self):
506 """ Add default project manually """
507 self.project = Project.objects.create_project('foo', None)
508 self.project.is_default = True
509 self.project.save()
510
511 def test_only_default_project(self):
512 """
513 No projects except default
514 => get the landing page
515 """
516 response = self.client.get(reverse('landing'))
517 self.assertTrue(self.LANDING_PAGE_TITLE in response.content)
518
519 def test_default_project_has_build(self):
520 """
521 Default project has a build, no other projects
522 => get the builds page
523 """
524 now = timezone.now()
525 build = Build.objects.create(project=self.project,
526 started_on=now,
527 completed_on=now)
528 build.save()
529
530 response = self.client.get(reverse('landing'))
531 self.assertEqual(response.status_code, 302,
532 'response should be a redirect')
533 self.assertTrue('/builds' in response.url,
534 'should redirect to builds')
535
536 def test_user_project_exists(self):
537 """
538 User has added a project (without builds)
539 => get the projects page
540 """
541 user_project = Project.objects.create_project('foo', None)
542 user_project.save()
543
544 response = self.client.get(reverse('landing'))
545 self.assertEqual(response.status_code, 302,
546 'response should be a redirect')
547 self.assertTrue('/projects' in response.url,
548 'should redirect to projects')
549
550 def test_user_project_has_build(self):
551 """
552 User has added a project (with builds)
553 => get the builds page
554 """
555 user_project = Project.objects.create_project('foo', None)
556 user_project.save()
557
558 now = timezone.now()
559 build = Build.objects.create(project=user_project,
560 started_on=now,
561 completed_on=now)
562 build.save()
563
564 response = self.client.get(reverse('landing'))
565 self.assertEqual(response.status_code, 302,
566 'response should be a redirect')
567 self.assertTrue('/builds' in response.url,
568 'should redirect to builds')
569
570class BuildDashboardTests(TestCase): 496class BuildDashboardTests(TestCase):
571 """ Tests for the build dashboard /build/X """ 497 """ Tests for the build dashboard /build/X """
572 498