Browse Source

Add unit test for restores API

Change-Id: Ia650f3b7feb2d9f52c1a0ae8c38579965017bdc8
YUHAN 4 months ago
parent
commit
50dc879eaf
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      karbor/tests/unit/api/v1/test_restores.py

+ 24
- 0
karbor/tests/unit/api/v1/test_restores.py View File

@@ -92,6 +92,30 @@ class RestoreApiTest(base.TestCase):
92 92
         self.controller.index(req)
93 93
         self.assertTrue(moak_get_all.called)
94 94
 
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
+
95 119
     @mock.patch(
96 120
         'karbor.api.v1.restores.RestoresController.'
97 121
         '_restore_get')

Loading…
Cancel
Save