All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Wood <michael.g.wood@intel.com>
To: toaster@yoctoproject.org
Subject: Re: [PATCH 5/5] toaster-tests: migrate landing page tests to Selenium
Date: Thu, 31 Mar 2016 15:41:37 +0100	[thread overview]
Message-ID: <56FD3721.6090703@intel.com> (raw)
In-Reply-To: <1458133834-26276-6-git-send-email-elliot.smith@intel.com>

Hijacking this with a bit of an RFC, but as I'm looking at tests at the 
moment, shall we start consolidating the tests in a single directory?

I was thinking:

├──bitbake/lib/toaster/tests
│   ├── browser
│   ├── views
│   ├── build
│   ├── api
│   ├── static
...etc

usage ./manage.py test tests [or tests.views etc]

Michael

On 16/03/16 13:10, Elliot Smith wrote:
> Signed-off-by: Elliot Smith <elliot.smith@intel.com>
> ---
>   .../lib/toaster/tests_browser/test_landing_page.py | 108 +++++++++++++++++++++
>   bitbake/lib/toaster/toastergui/tests.py            |  74 --------------
>   2 files changed, 108 insertions(+), 74 deletions(-)
>   create mode 100644 bitbake/lib/toaster/tests_browser/test_landing_page.py
>
> 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 0000000..8343630
> --- /dev/null
> +++ b/bitbake/lib/toaster/tests_browser/test_landing_page.py
> @@ -0,0 +1,108 @@
> +#! /usr/bin/env python
> +# ex:ts=4:sw=4:sts=4:et
> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
> +#
> +# BitBake Toaster Implementation
> +#
> +# Copyright (C) 2013-2016 Intel Corporation
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License version 2 as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program; if not, write to the Free Software Foundation, Inc.,
> +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +
> +from django.core.urlresolvers import reverse
> +from django.utils import timezone
> +from toaster.tests_browser.selenium_helpers import SeleniumTestCase
> +
> +from orm.models import Project, Build
> +
> +class TestLandingPage(SeleniumTestCase):
> +    """ Tests for redirects on the landing page """
> +
> +    PROJECT_NAME = 'test project'
> +    LANDING_PAGE_TITLE = 'This is Toaster'
> +    CLI_BUILDS_PROJECT_NAME = 'command line builds'
> +
> +    def setUp(self):
> +        """ Add default project manually """
> +        self.project = Project.objects.create_project(
> +            self.CLI_BUILDS_PROJECT_NAME,
> +            None
> +        )
> +        self.project.is_default = True
> +        self.project.save()
> +
> +    def test_only_default_project(self):
> +        """
> +        No projects except default
> +        => should see the landing page
> +        """
> +        self.get(reverse('landing'))
> +        self.assertTrue(self.LANDING_PAGE_TITLE in self.get_page_source())
> +
> +    def test_default_project_has_build(self):
> +        """
> +        Default project has a build, no other projects
> +        => should see the builds page
> +        """
> +        now = timezone.now()
> +        build = Build.objects.create(project=self.project,
> +                                     started_on=now,
> +                                     completed_on=now)
> +        build.save()
> +
> +        self.get(reverse('landing'))
> +
> +        elements = self.find_all('#allbuildstable')
> +        self.assertEqual(len(elements), 1, 'should redirect to builds')
> +        content = self.get_page_source()
> +        self.assertFalse(self.PROJECT_NAME in content,
> +                         'should not show builds for project %s' % self.PROJECT_NAME)
> +        self.assertTrue(self.CLI_BUILDS_PROJECT_NAME in content,
> +                        'should show builds for cli project')
> +
> +    def test_user_project_exists(self):
> +        """
> +        User has added a project (without builds)
> +        => should see the projects page
> +        """
> +        user_project = Project.objects.create_project('foo', None)
> +        user_project.save()
> +
> +        self.get(reverse('landing'))
> +
> +        elements = self.find_all('#projectstable')
> +        self.assertEqual(len(elements), 1, 'should redirect to projects')
> +
> +    def test_user_project_has_build(self):
> +        """
> +        User has added a project (with builds), command line builds doesn't
> +        => should see the builds page
> +        """
> +        user_project = Project.objects.create_project(self.PROJECT_NAME, None)
> +        user_project.save()
> +
> +        now = timezone.now()
> +        build = Build.objects.create(project=user_project,
> +                                     started_on=now,
> +                                     completed_on=now)
> +        build.save()
> +
> +        self.get(reverse('landing'))
> +
> +        elements = self.find_all('#allbuildstable')
> +        self.assertEqual(len(elements), 1, 'should redirect to builds')
> +        content = self.get_page_source()
> +        self.assertTrue(self.PROJECT_NAME in content,
> +                        'should show builds for project %s' % self.PROJECT_NAME)
> +        self.assertFalse(self.CLI_BUILDS_PROJECT_NAME in content,
> +                         'should not show builds for cli project')
> diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
> index 6975ac1..eebd1b7 100644
> --- a/bitbake/lib/toaster/toastergui/tests.py
> +++ b/bitbake/lib/toaster/toastergui/tests.py
> @@ -493,80 +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:
> -    # "Instance of 'WSGIRequest' has no 'url' member (no-member)"
> -    # (see https://github.com/landscapeio/pylint-django/issues/42)
> -    # pylint: disable=E1103
> -
> -    LANDING_PAGE_TITLE = 'This is Toaster'
> -
> -    def setUp(self):
> -        """ Add default project manually """
> -        self.project = Project.objects.create_project('foo', None)
> -        self.project.is_default = True
> -        self.project.save()
> -
> -    def test_only_default_project(self):
> -        """
> -        No projects except default
> -        => get the landing page
> -        """
> -        response = self.client.get(reverse('landing'))
> -        self.assertTrue(self.LANDING_PAGE_TITLE in response.content)
> -
> -    def test_default_project_has_build(self):
> -        """
> -        Default project has a build, no other projects
> -        => get the builds page
> -        """
> -        now = timezone.now()
> -        build = Build.objects.create(project=self.project,
> -                                     started_on=now,
> -                                     completed_on=now)
> -        build.save()
> -
> -        response = self.client.get(reverse('landing'))
> -        self.assertEqual(response.status_code, 302,
> -                         'response should be a redirect')
> -        self.assertTrue('/builds' in response.url,
> -                        'should redirect to builds')
> -
> -    def test_user_project_exists(self):
> -        """
> -        User has added a project (without builds)
> -        => get the projects page
> -        """
> -        user_project = Project.objects.create_project('foo', None)
> -        user_project.save()
> -
> -        response = self.client.get(reverse('landing'))
> -        self.assertEqual(response.status_code, 302,
> -                         'response should be a redirect')
> -        self.assertTrue('/projects' in response.url,
> -                        'should redirect to projects')
> -
> -    def test_user_project_has_build(self):
> -        """
> -        User has added a project (with builds)
> -        => get the builds page
> -        """
> -        user_project = Project.objects.create_project('foo', None)
> -        user_project.save()
> -
> -        now = timezone.now()
> -        build = Build.objects.create(project=user_project,
> -                                     started_on=now,
> -                                     completed_on=now)
> -        build.save()
> -
> -        response = self.client.get(reverse('landing'))
> -        self.assertEqual(response.status_code, 302,
> -                         'response should be a redirect')
> -        self.assertTrue('/builds' in response.url,
> -                        'should redirect to builds')
> -
>   class BuildDashboardTests(TestCase):
>       """ Tests for the build dashboard /build/X """
>   



  reply	other threads:[~2016-03-31 14:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 13:10 [PATCH 0/5] Migrate Toaster tests to Selenium Elliot Smith
2016-03-16 13:10 ` [PATCH 1/5] toaster-tests: migrate to Selenium for UI tests Elliot Smith
2016-03-16 13:10 ` [PATCH 2/5] toaster-tests: migrate all builds page and project page tests to Selenium Elliot Smith
2016-03-16 13:10 ` [PATCH 3/5] toaster-tests: migrate project builds " Elliot Smith
2016-03-16 13:10 ` [PATCH 4/5] toaster-tests: migrate all projects " Elliot Smith
2016-03-16 13:10 ` [PATCH 5/5] toaster-tests: migrate landing " Elliot Smith
2016-03-31 14:41   ` Michael Wood [this message]
2016-03-31 15:06     ` Smith, Elliot
2016-03-31 15:12       ` Michael Wood
2016-03-31 19:04         ` Michael Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56FD3721.6090703@intel.com \
    --to=michael.g.wood@intel.com \
    --cc=toaster@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.