Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 2D18DE00F54; Tue, 12 Jul 2016 12:55:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.20 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id E1C2BE00F25 for ; Tue, 12 Jul 2016 12:55:49 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 12 Jul 2016 12:55:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,353,1464678000"; d="scan'208";a="993917832" Received: from alimonb-mobl1.zpn.intel.com ([10.219.5.159]) by orsmga001.jf.intel.com with ESMTP; 12 Jul 2016 12:55:50 -0700 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= To: toaster@yoctoproject.org Date: Tue, 12 Jul 2016 14:56:08 -0500 Message-Id: <1468353368-7065-2-git-send-email-anibal.limon@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468353368-7065-1-git-send-email-anibal.limon@linux.intel.com> References: <1468353368-7065-1-git-send-email-anibal.limon@linux.intel.com> MIME-Version: 1.0 Cc: libertad.gonzalez.de.la.cruz@intel.com Subject: [PATCH 2/2] toaster/tests: browser add class SeleniumTestCaseBase X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2016 19:55:51 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new module with base class SeleniumTestCaseBase only with inherit of unittest.TestCase for reuse selenium helper in functional testing of Toaster outside django environment. Add class SeleniumTestCase with multiple inherit of StaticLiveServerTestCase and SeleniumTestCaseBase for don't broke things. Signed-off-by: Aníbal Limón --- lib/toaster/tests/browser/selenium_helpers.py | 40 ++++++++++++++++++++++ lib/toaster/tests/browser/selenium_helpers_base.py | 11 +++--- 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 lib/toaster/tests/browser/selenium_helpers.py diff --git a/lib/toaster/tests/browser/selenium_helpers.py b/lib/toaster/tests/browser/selenium_helpers.py new file mode 100644 index 0000000..ddb43fd --- /dev/null +++ b/lib/toaster/tests/browser/selenium_helpers.py @@ -0,0 +1,40 @@ +#! /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. +# +# The Wait class and some of SeleniumDriverHelper and SeleniumTestCase are +# modified from Patchwork, released under the same licence terms as Toaster: +# https://github.com/dlespiau/patchwork/blob/master/patchwork/tests.browser.py + +from django.contrib.staticfiles.testing import StaticLiveServerTestCase +from tests.browser.selenium_helpers_base import SeleniumTestCaseBase + +""" +Helper methods for creating Toaster Selenium tests which run within +the context of Django unit tests. +""" + +class SeleniumTestCase(SeleniumTestCaseBase, StaticLiveServerTestCase): + """ + NB StaticLiveServerTestCase is used as the base test case so that + static files are served correctly in a Selenium test run context; see + https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/#specialized-test-case-to-support-live-testing + """ + pass diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toaster/tests/browser/selenium_helpers_base.py index 54db2e8..8785a60 100644 --- a/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/lib/toaster/tests/browser/selenium_helpers_base.py @@ -24,14 +24,13 @@ # https://github.com/dlespiau/patchwork/blob/master/patchwork/tests.browser.py """ -Helper methods for creating Toaster Selenium tests which run within -the context of Django unit tests. +Base helper methods for creating Toaster Selenium tests. """ import os import time +import unittest -from django.contrib.staticfiles.testing import StaticLiveServerTestCase from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException, \ @@ -114,7 +113,7 @@ class Wait(WebDriverWait): raise TimeoutException(message) -class SeleniumTestCase(StaticLiveServerTestCase): +class SeleniumTestCaseBase(unittest.TestCase): """ NB StaticLiveServerTestCase is used as the base test case so that static files are served correctly in a Selenium test run context; see @@ -125,7 +124,7 @@ class SeleniumTestCase(StaticLiveServerTestCase): def setUpClass(cls): """ Create a webdriver driver at the class level """ - super(SeleniumTestCase, cls).setUpClass() + super(SeleniumTestCaseBase, cls).setUpClass() # instantiate the Selenium webdriver once for all the test methods # in this test case @@ -137,7 +136,7 @@ class SeleniumTestCase(StaticLiveServerTestCase): """ Clean up webdriver driver """ cls.driver.quit() - super(SeleniumTestCase, cls).tearDownClass() + super(SeleniumTestCaseBase, cls).tearDownClass() def get(self, url): """ -- 2.1.4