add some unit tests for ExecuteCommand
Sem-Ver: bugfix Change-Id: Ia87cf70b1b120f01d0d430c5d00f2a2120ee1890
This commit is contained in:
parent
5dcea60830
commit
adf0f27de6
59
synergy/tests/unit/test_client_command_executecommand.py
Normal file
59
synergy/tests/unit/test_client_command_executecommand.py
Normal file
@ -0,0 +1,59 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""
|
||||
Test the ExecuteCommand class.
|
||||
|
||||
"""
|
||||
|
||||
import mock
|
||||
|
||||
from synergy.client.command import ExecuteCommand
|
||||
from synergy.client.command import HTTPCommand
|
||||
from synergy.tests import base
|
||||
|
||||
|
||||
class TestExecuteCommand(base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestExecuteCommand, self).setUp()
|
||||
self.execute_command = ExecuteCommand(name="dummy_execmd")
|
||||
|
||||
def test_execute_no_args(self):
|
||||
"""Check the URL and payload."""
|
||||
with mock.patch.object(HTTPCommand, 'execute') as m:
|
||||
self.execute_command.execute(
|
||||
synergy_url="",
|
||||
manager="Manager",
|
||||
command="command")
|
||||
|
||||
expected_payload = {
|
||||
"manager": "Manager",
|
||||
"command": "command",
|
||||
"args": "{}"}
|
||||
m.assert_called_once_with("/synergy/execute", expected_payload)
|
||||
|
||||
def test_execute_with_args(self):
|
||||
"""Check the URL and payload."""
|
||||
with mock.patch.object(HTTPCommand, 'execute') as m:
|
||||
self.execute_command.execute(
|
||||
synergy_url="",
|
||||
manager="Manager",
|
||||
command="command",
|
||||
args={"test": {"what": "yes"}})
|
||||
|
||||
expected_payload = {
|
||||
"manager": "Manager",
|
||||
"command": "command",
|
||||
"args": '{"test": {"what": "yes"}}'}
|
||||
m.assert_called_once_with("/synergy/execute", expected_payload)
|
Loading…
x
Reference in New Issue
Block a user