forked from openlp/openlp
First couple of (example) tests and a README file to go with it.
This commit is contained in:
parent
0450866e73
commit
8a4f143878
34
tests/README.txt
Normal file
34
tests/README.txt
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
Tests for OpenLP
|
||||||
|
================
|
||||||
|
|
||||||
|
This directory contains unit tests for OpenLP. The ``functional`` directory contains functional unit tests.
|
||||||
|
|
||||||
|
Prerequisites
|
||||||
|
-------------
|
||||||
|
|
||||||
|
In order to run the unit tests, you will need the following Python packages/libraries installed:
|
||||||
|
|
||||||
|
- Mock
|
||||||
|
- Nose
|
||||||
|
|
||||||
|
On Ubuntu you can simple install the python-mock and python-nose packages. Most other distributions will also have these
|
||||||
|
packages. On Windows and Mac OS X you will need to use ``pip`` or ``easy_install`` to install these packages.
|
||||||
|
|
||||||
|
Running the Tests
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
To run the tests, navigate to the root directory of the OpenLP project, and then run the following command::
|
||||||
|
|
||||||
|
nosetests -v tests
|
||||||
|
|
||||||
|
Or, to run only the functional tests, run the following command::
|
||||||
|
|
||||||
|
nosetests -v tests/functional
|
||||||
|
|
||||||
|
Or, to run only a particular test suite within a file, run the following command::
|
||||||
|
|
||||||
|
nosetests -v tests/functional/test_applocation.py
|
||||||
|
|
||||||
|
Finally, to only run a particular test, run the following command::
|
||||||
|
|
||||||
|
nosetests -v tests/functional/test_applocation.py:TestAppLocation.get_frozen_path_test
|
1
tests/functional/openlp_core_utils/__init__.py
Normal file
1
tests/functional/openlp_core_utils/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__author__ = 'raoul'
|
37
tests/functional/openlp_core_utils/test_applocation.py
Normal file
37
tests/functional/openlp_core_utils/test_applocation.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"""
|
||||||
|
Functional tests to test the AppLocation class and related methods.
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from mock import patch
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation, _get_frozen_path
|
||||||
|
|
||||||
|
class TestAppLocation(TestCase):
|
||||||
|
"""
|
||||||
|
A test suite to test out various methods around the AppLocation class.
|
||||||
|
"""
|
||||||
|
def get_frozen_path_test(self):
|
||||||
|
"""
|
||||||
|
Test the _get_frozen_path() function
|
||||||
|
"""
|
||||||
|
sys.frozen = None
|
||||||
|
assert _get_frozen_path(u'frozen', u'not frozen') == u'not frozen', u'Should return "not frozen"'
|
||||||
|
sys.frozen = 1
|
||||||
|
assert _get_frozen_path(u'frozen', u'not frozen') == u'frozen', u'Should return "frozen"'
|
||||||
|
|
||||||
|
def get_data_path_with_custom_location_test(self):
|
||||||
|
"""
|
||||||
|
Test the AppLocation.get_data_path() method when a custom location is set in the settings
|
||||||
|
"""
|
||||||
|
with patch(u'openlp.core.utils.Settings') as mocked_class:
|
||||||
|
mocked_settings = mocked_class.return_value
|
||||||
|
mocked_settings.contains.return_value = True
|
||||||
|
mocked_settings.value.return_value.toString.return_value = u'test/dir'
|
||||||
|
data_path = AppLocation.get_data_path()
|
||||||
|
mocked_settings.contains.assert_called_with(u'advanced/data path')
|
||||||
|
mocked_settings.value.assert_called_with(u'advanced/data path')
|
||||||
|
mocked_settings.value.return_value.toString.assert_called_with()
|
||||||
|
assert data_path == u'test/dir', u'Result should be "test/dir"'
|
Loading…
Reference in New Issue
Block a user