← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mzibricky/openlp/testing into lp:openlp

 

matysek has proposed merging lp:~mzibricky/openlp/testing into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~mzibricky/openlp/testing/+merge/73791

Added test case example for automated testing of gui.
-- 
https://code.launchpad.net/~mzibricky/openlp/testing/+merge/73791
Your team OpenLP Core is requested to review the proposed merge of lp:~mzibricky/openlp/testing into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py	2011-08-26 11:04:56 +0000
+++ openlp/core/__init__.py	2011-09-02 12:02:17 +0000
@@ -261,8 +261,10 @@
     app.setApplicationName(u'OpenLP')
     app.setApplicationVersion(get_application_version()[u'version'])
     # Instance check
-    if app.isAlreadyRunning():
-        sys.exit()
+    if not options.testing:
+        # Instance check
+        if app.isAlreadyRunning():
+            sys.exit()
     # First time checks in settings
     if not QtCore.QSettings().value(u'general/has run wizard',
         QtCore.QVariant(False)).toBool():
@@ -284,5 +286,7 @@
     # Do not run method app.exec_() when running gui tests
     if options.testing:
         app.run(qt_args, testing=True)
+        # For gui tests we need access to window intances and their components
+        return app
     else:
         sys.exit(app.run(qt_args))

=== modified file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py	2011-08-25 20:14:02 +0000
+++ scripts/check_dependencies.py	2011-09-02 12:02:17 +0000
@@ -80,6 +80,7 @@
     ('sqlite', ' (SQLite 2 support)'),
     ('MySQLdb', ' (MySQL support)'),
     ('psycopg2', ' (PostgreSQL support)'),
+    ('pytest', ' (testing framework)'),
 ]
 
 w = sys.stdout.write

=== added directory 'testing'
=== added file 'testing/conftest.py'
--- testing/conftest.py	1970-01-01 00:00:00 +0000
+++ testing/conftest.py	2011-09-02 12:02:17 +0000
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2011 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan      #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan,      #
+# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias     #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,    #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund             #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# 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., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+
+"""
+Configuration file for pytest framework.
+"""
+
+from openlp.core import main as openlp_main
+
+
+# Test function argument to make openlp gui instance persistent for all tests.
+# All test cases have to access the same instance. To allow create multiple
+# instances it would be necessary use diffrent configuraion and data files.
+# Created instance will use your OpenLP settings.
+def pytest_funcarg__openlpapp(request):
+    def setup():
+        return openlp_main(['--testing'])
+    def teardown(app):
+        pass
+    return request.cached_setup(setup=setup, teardown=teardown, scope='session')

=== added file 'testing/run.py'
--- testing/run.py	1970-01-01 00:00:00 +0000
+++ testing/run.py	2011-09-02 12:02:17 +0000
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2011 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan      #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan,      #
+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias     #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,    #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund             #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# 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., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+
+"""
+This script is used to run set of automated tests of OpenLP. To start tests,
+simply run this script::
+
+    @:~$ ./run.py
+
+"""
+
+import os.path
+import sys
+
+TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
+SRC_PATH = os.path.join(TESTS_PATH, '..')
+
+PYTEST_OPTIONS = [TESTS_PATH]
+
+# Extend python PATH with openlp source
+sys.path.insert(0, SRC_PATH)
+
+# Python testing framework
+# http://pytest.org
+import pytest
+
+
+def main():
+    print 'pytest options:', PYTEST_OPTIONS
+    pytest.main(PYTEST_OPTIONS)
+
+
+if __name__ == u'__main__':
+    main()

=== added file 'testing/test_app.py'
--- testing/test_app.py	1970-01-01 00:00:00 +0000
+++ testing/test_app.py	2011-09-02 12:02:17 +0000
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2011 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan      #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan,      #
+# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias     #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,    #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund             #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# 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., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+
+from openlp.core import OpenLP
+from openlp.core.ui.mainwindow import MainWindow
+
+
+def test_start_app(openlpapp):
+    assert type(openlpapp) == OpenLP
+    assert type(openlpapp.mainWindow) == MainWindow
+    assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.0'


Follow ups