openlp/tests/openlp_core/projectors/test_projector_constants.py

84 lines
3.4 KiB
Python
Raw Normal View History

2017-05-12 09:51:56 +00:00
# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2020 OpenLP Developers #
2019-04-13 13:00:22 +00:00
# ---------------------------------------------------------------------- #
# 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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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, see <https://www.gnu.org/licenses/>. #
##########################################################################
2017-05-12 09:51:56 +00:00
"""
2017-11-10 11:59:38 +00:00
Package to test the openlp.core.projectors.constants module.
2017-05-12 09:51:56 +00:00
"""
2017-08-06 07:23:26 +00:00
from unittest import TestCase
2018-10-02 04:39:42 +00:00
2017-12-25 08:44:30 +00:00
from openlp.core.projectors import constants
from openlp.core.projectors.constants import STATUS_CODE, STATUS_MSG
2017-05-12 09:51:56 +00:00
class TestProjectorConstants(TestCase):
"""
Test specific functions in the projector constants module.
"""
2017-12-25 08:44:30 +00:00
def test_defined_codes_in_status_code(self):
"""
Test defined status/error codes have equivalent strings
"""
check = []
missing_str = []
# GIVEN: List of defined E_* and S_* items defined in constants
2019-05-04 05:25:07 +00:00
2017-12-25 08:44:30 +00:00
for item in constants.__dict__:
if item.startswith('E_') or item.startswith('S_'):
check.append(item)
2019-05-04 05:25:07 +00:00
# WHEN: Verify items were addeded to check
2017-12-25 08:44:30 +00:00
for item in check:
if constants.__dict__[item] not in STATUS_CODE:
missing_str.append(item)
# THEN: There should be no missing items
assert 0 == len(missing_str), 'Status string missing: {msg}'.format(msg=missing_str)
def test_status_code_in_status_message(self):
"""
Test if entries in STATUS_CODE have equivalent descriptions in STATUS_MSG
"""
missing_msg = []
# GIVEN: Test items
check = STATUS_CODE
# WHEN: Verify each entry in STATUS_MSG against STATUS_CODE
for item in check:
if item not in STATUS_MSG:
missing_msg.append(item)
# THEN: There should be no missing items
assert 0 == len(missing_msg), 'Status message missing: {msg}'.format(msg=missing_msg)
2017-06-01 22:35:57 +00:00
def test_build_pjlink_video_label(self):
2017-05-12 09:51:56 +00:00
"""
Test building PJLINK_DEFAULT_CODES dictionary
"""
# GIVEN: Test data
from tests.resources.projector.data import TEST_VIDEO_CODES
# WHEN: Import projector PJLINK_DEFAULT_CODES
2017-11-10 11:59:38 +00:00
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES
2017-05-12 09:51:56 +00:00
# THEN: Verify dictionary was build correctly
2017-08-06 07:23:26 +00:00
self.assertEqual(PJLINK_DEFAULT_CODES, TEST_VIDEO_CODES, 'PJLink video strings should match')