From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: toaster@yoctoproject.org
Cc: libertad.gonzalez.de.la.cruz@intel.com
Subject: [PATCH 2/2] toaster/tests: browser add class SeleniumTestCaseBase
Date: Tue, 12 Jul 2016 14:56:08 -0500 [thread overview]
Message-ID: <1468353368-7065-2-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1468353368-7065-1-git-send-email-anibal.limon@linux.intel.com>
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 <anibal.limon@linux.intel.com>
---
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
next prev parent reply other threads:[~2016-07-12 19:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 19:56 [PATCH 1/2] toaster/tests: browser rename selenium_helpers to selenium_helpers_base Aníbal Limón
2016-07-12 19:56 ` Aníbal Limón [this message]
2016-07-14 13:25 ` Smith, Elliot
2016-07-14 15:55 ` Aníbal Limón
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=1468353368-7065-2-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=libertad.gonzalez.de.la.cruz@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.