openlp/tests/functional/openlp_core_utils/test_utils.py

36 lines
1.3 KiB
Python
Raw Normal View History

2012-12-07 20:50:38 +00:00
"""
Functional tests to test the AppLocation class and related methods.
"""
from unittest import TestCase
from mock import patch
from openlp.core.utils import get_filesystem_encoding, _get_frozen_path
2012-12-07 20:50:38 +00:00
class TestUtils(TestCase):
"""
A test suite to test out various methods around the AppLocation class.
"""
def get_filesystem_encoding_test(self):
"""
Test the get_filesystem_encoding() function
"""
assert False, u'This test needs to be written'
def get_frozen_path_test(self):
"""
Test the _get_frozen_path() function
"""
with patch(u'openlp.core.utils.sys') as mocked_sys:
# GIVEN: The sys module "without" a "frozen" attribute
mocked_sys.frozen = None
# WHEN: We call _get_frozen_path() with two parameters
# THEN: The non-frozen parameter is returned
assert _get_frozen_path(u'frozen', u'not frozen') == u'not frozen', u'Should return "not frozen"'
# GIVEN: The sys module *with* a "frozen" attribute
mocked_sys.frozen = 1
# WHEN: We call _get_frozen_path() with two parameters
# THEN: The frozen parameter is returned
assert _get_frozen_path(u'frozen', u'not frozen') == u'frozen', u'Should return "frozen"'