From 078b67dfa597f652181bf8d97909ef2482f3a183 Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Mon, 17 Mar 2014 10:13:17 -0700 Subject: [PATCH] Fix MediaType() call and add tests for / and /v1 --- teeth_agent/api/controllers/v1/__init__.py | 4 +++- teeth_agent/tests/api.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/teeth_agent/api/controllers/v1/__init__.py b/teeth_agent/api/controllers/v1/__init__.py index 998e6e446..3fbd9cd25 100644 --- a/teeth_agent/api/controllers/v1/__init__.py +++ b/teeth_agent/api/controllers/v1/__init__.py @@ -96,7 +96,9 @@ class V1(base.APIBase): '', bookmark=True) ] - v1.media_types = [MediaType('application/json')] + v1.media_types = [MediaType('application/json', + ('application/vnd.openstack.' + 'ironic-python-agent.v1+json'))] return v1 diff --git a/teeth_agent/tests/api.py b/teeth_agent/tests/api.py index 14348bb9c..655bbae1c 100644 --- a/teeth_agent/tests/api.py +++ b/teeth_agent/tests/api.py @@ -44,6 +44,20 @@ class TestTeethAPI(unittest.TestCase): client = test.Client(api, wrappers.BaseResponse) return client.open(self._get_env_builder(method, path, data, query)) + def test_root(self): + mock_agent = mock.MagicMock() + api_server = app.setup_app(mock_agent) + + response = self._make_request(api_server, 'GET', '/') + self.assertEqual(response.status, '200 OK') + + def test_v1_root(self): + mock_agent = mock.MagicMock() + api_server = app.setup_app(mock_agent) + + response = self._make_request(api_server, 'GET', '/v1') + self.assertEqual(response.status, '200 OK') + def test_get_agent_status(self): status = agent.TeethAgentStatus('TEST_MODE', time.time(), 'v72ac9') mock_agent = mock.MagicMock()