forked from openlp/openlp
Merge branch 'Issue-740' into 'master'
Handle load of Service with missing Plugin - Issue 740 Closes #740 See merge request openlp/openlp!288
This commit is contained in:
commit
53b061dac6
@ -147,11 +147,15 @@ class State(LogMixin, metaclass=Singleton):
|
|||||||
:return: Have the preconditions been met.
|
:return: Have the preconditions been met.
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
if self.modules[name].requires is None:
|
try:
|
||||||
return self.modules[name].pass_preconditions
|
if self.modules[name].requires is None:
|
||||||
else:
|
return self.modules[name].pass_preconditions
|
||||||
mod = self.modules[name].requires
|
else:
|
||||||
return self.modules[mod].pass_preconditions
|
mod = self.modules[name].requires
|
||||||
|
return self.modules[mod].pass_preconditions
|
||||||
|
except KeyError:
|
||||||
|
# Module is missing so therefore not found.
|
||||||
|
return False
|
||||||
|
|
||||||
def list_plugins(self):
|
def list_plugins(self):
|
||||||
"""
|
"""
|
||||||
|
@ -207,3 +207,20 @@ def test_check_preconditions_required_module(state):
|
|||||||
|
|
||||||
# THEN: The correct result should be returned
|
# THEN: The correct result should be returned
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_preconditions_missing_module(state):
|
||||||
|
"""
|
||||||
|
Test that the check_preconditions() method returns the correct attribute when the module is missing
|
||||||
|
"""
|
||||||
|
# GIVEN: A State with two modules
|
||||||
|
State().modules.update({
|
||||||
|
'test_pre2': MagicMock(requires='test_pre3', pass_preconditions=True),
|
||||||
|
'test_pre3': MagicMock(requires=None, pass_preconditions=False)
|
||||||
|
})
|
||||||
|
|
||||||
|
# WHEN: check_preconditions() is called
|
||||||
|
result = State().check_preconditions('test_pre1')
|
||||||
|
|
||||||
|
# THEN: The correct result should be returned
|
||||||
|
assert result is False
|
||||||
|
Loading…
Reference in New Issue
Block a user