summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYUHAN <yuhan@cmss.chinamobile.com>2018-11-27 03:33:25 +0800
committerYUHAN <yuhan@cmss.chinamobile.com>2018-11-27 04:10:48 +0800
commit50dc879eafa2326fa16b2d3904af0ec4781935ba (patch)
treec26bd8ffa7926ade661ad0f8a81662381b10217b
parent57c04d1eeb14c86186ad5103c032b56fafbf6152 (diff)
Add unit test for restores API
Notes
Notes (review): Code-Review+2: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Workflow+1: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 27 Nov 2018 01:21:37 +0000 Reviewed-on: https://review.openstack.org/620030 Project: openstack/karbor Branch: refs/heads/master
-rw-r--r--karbor/tests/unit/api/v1/test_restores.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/karbor/tests/unit/api/v1/test_restores.py b/karbor/tests/unit/api/v1/test_restores.py
index 79fb177..ad9dbe2 100644
--- a/karbor/tests/unit/api/v1/test_restores.py
+++ b/karbor/tests/unit/api/v1/test_restores.py
@@ -93,6 +93,30 @@ class RestoreApiTest(base.TestCase):
93 self.assertTrue(moak_get_all.called) 93 self.assertTrue(moak_get_all.called)
94 94
95 @mock.patch( 95 @mock.patch(
96 'karbor.api.v1.restores.RestoresController._get_all')
97 def test_restore_index_limit_offset(self, mock_get_all):
98 req = fakes.HTTPRequest.blank(
99 '/v1/restores?limit=2&offset=1')
100 self.controller.index(req)
101 self.assertTrue(mock_get_all.called)
102
103 req = fakes.HTTPRequest.blank('/v1/restores?limit=-1&offset=1')
104 self.assertRaises(exc.HTTPBadRequest,
105 self.controller.index,
106 req)
107
108 req = fakes.HTTPRequest.blank('/v1/restores?limit=a&offset=1')
109 self.assertRaises(exc.HTTPBadRequest,
110 self.controller.index,
111 req)
112
113 url = '/v1/restores?limit=2&offset=43543564546567575'
114 req = fakes.HTTPRequest.blank(url)
115 self.assertRaises(exc.HTTPBadRequest,
116 self.controller.index,
117 req)
118
119 @mock.patch(
96 'karbor.api.v1.restores.RestoresController.' 120 'karbor.api.v1.restores.RestoresController.'
97 '_restore_get') 121 '_restore_get')
98 def test_restore_show(self, moak_restore_get): 122 def test_restore_show(self, moak_restore_get):