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 <[email protected]>
---
 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

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Reply via email to