Skip to content

Commit

Permalink
Testcase fix
Browse files Browse the repository at this point in the history
tendrl-bug-id: Tendrl#1080
bugzilla: 1688630

Signed-off-by: GowthamShanmugasundaram <gshanmug@redhat.com>
  • Loading branch information
GowthamShanmugam committed Apr 27, 2019
1 parent e382fdf commit fbe5192
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import maps
import mock
from mock import patch
import pytest

from tendrl.commons.flows.exceptions import FlowExecutionFailedError
from tendrl.commons.objects.node.flows.stop_services import \
StopServices
import tendrl.commons.objects.node_context as node
Expand All @@ -27,11 +29,18 @@ def service_success(param):


def service_failed(param):
return 'error', '', 0
return '', 'error', 0


def service_info(*args, **kwargs):
return {"exists": True, "running": True}
return {"exists": True, "running": True, "error": []}


def service_error(*args, **kwargs):
return {"exists": True,
"running": False,
"error": ["permission issue"]
}


def mock_log(*args, **kwargs):
Expand Down Expand Up @@ -106,6 +115,6 @@ def test_run():
assert ret_val is True
with patch.object(logger, 'log', mock_log):
with patch.object(cmd_utils.Command, 'run', service_failed):
with patch.object(Service, 'get_service_info', service_info):
ret_val = obj.run()
assert ret_val is False
with patch.object(Service, 'get_service_info', service_error):
with pytest.raises(FlowExecutionFailedError):
obj.run()
8 changes: 4 additions & 4 deletions tendrl/commons/tests/utils/test_service_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def test_constructor():

def test_status():
service_status = ServiceStatus("service_status")
ret = service_status.status()
ret, _ = service_status.status()
assert ret is False
with patch.object(cmd_utils.Command, 'run') as mock_run:
mock_run.return_value = run(True)
ret = service_status.status()
ret, _ = service_status.status()
assert ret is False
with patch.object(cmd_utils.Command, 'run') as mock_run:
mock_run.return_value = run(False)
ret = service_status.status()
ret, _ = service_status.status()
assert ret is True


def test_exists():
service_status = ServiceStatus("service_status")
ret = service_status.exists()
ret, _ = service_status.exists()
assert ret is False

0 comments on commit fbe5192

Please sign in to comment.