update tests to use new command results

This commit is contained in:
Russell Haering 2014-01-02 13:19:10 -08:00
parent f230e7efbe
commit a44af2d5b7

@ -22,6 +22,8 @@ import unittest
from werkzeug import test
from werkzeug import wrappers
from teeth_rest import encoding
from teeth_agent import api
from teeth_agent import base
@ -57,16 +59,20 @@ class TestTeethAPI(unittest.TestCase):
self.assertEqual(data['version'], status.version)
def test_execute_agent_command_success(self):
result = {'test': 'result'}
mock_agent = mock.MagicMock()
mock_agent.execute_command.return_value = result
api_server = api.TeethAgentAPIServer(mock_agent)
command = {
'name': 'do_things',
'params': {'key': 'value'},
}
result = base.SyncCommandResult(command['name'],
command['params'],
True,
{'test': 'result'})
mock_agent = mock.MagicMock()
mock_agent.execute_command.return_value = result
api_server = api.TeethAgentAPIServer(mock_agent)
response = self._make_request(api_server,
'POST',
'/v1.0/command',
@ -78,7 +84,8 @@ class TestTeethAPI(unittest.TestCase):
self.assertEqual(kwargs, {'key': 'value'})
self.assertEqual(response.status_code, 200)
data = json.loads(response.data)
self.assertEqual(data, {'command': command, 'result': result})
expected_result = result.serialize(encoding.SerializationViews.PUBLIC)
self.assertEqual(data, expected_result)
def test_execute_agent_command_validation(self):
mock_agent = mock.MagicMock()