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
|
|
|
|
|
2012-12-07 20:52:55 +00:00
|
|
|
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'
|
|
|
|
|
2012-12-07 20:52:55 +00:00
|
|
|
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"'
|
|
|
|
|