Browse Source

add a unitest for api of verification

Change-Id: I9dd15ff0f35738676871771bd78b225bcda9684c
yuanliu 4 months ago
parent
commit
c74b622ff7
1 changed files with 21 additions and 4 deletions
  1. 21
    4
      karbor/tests/unit/api/v1/test_verifications.py

+ 21
- 4
karbor/tests/unit/api/v1/test_verifications.py View File

@@ -76,19 +76,36 @@ class VerificationApiTest(base.TestCase):
76 76
     @mock.patch(
77 77
         'karbor.api.v1.verifications.'
78 78
         'VerificationsController._get_all')
79
-    def test_verification_list_detail(self, moak_get_all):
79
+    def test_verification_list_detail(self, mock_get_all):
80 80
         req = fakes.HTTPRequest.blank('/v1/verifications')
81 81
         self.controller.index(req)
82
-        self.assertTrue(moak_get_all.called)
82
+        self.assertTrue(mock_get_all.called)
83
+
84
+    @mock.patch(
85
+        'karbor.api.v1.verifications.'
86
+        'VerificationsController._get_all')
87
+    @mock.patch('karbor.api.common.ViewBuilder._get_collection_links')
88
+    def test_verification_list_detail_with_verifications_links(self,
89
+                                                               mock_get_links,
90
+                                                               mock_get_all):
91
+        except_value = [{
92
+            "rel": "next",
93
+            "href": "/v1/verifications?marker"
94
+        }]
95
+        req = fakes.HTTPRequest.blank('/v1/verifications')
96
+        mock_get_links.return_value = except_value
97
+        return_value = self.controller.index(req)
98
+        self.assertTrue(mock_get_all.called)
99
+        self.assertEqual(return_value['verifications_links'], except_value)
83 100
 
84 101
     @mock.patch(
85 102
         'karbor.api.v1.verifications.'
86 103
         'VerificationsController._verification_get')
87
-    def test_verification_show(self, moak_verification_get):
104
+    def test_verification_show(self, mock_verification_get):
88 105
         req = fakes.HTTPRequest.blank('/v1/verifications')
89 106
         self.controller.show(
90 107
             req, '2a9ce1f3-cc1a-4516-9435-0ebb13caa398')
91
-        self.assertTrue(moak_verification_get.called)
108
+        self.assertTrue(mock_verification_get.called)
92 109
 
93 110
     def test_verification_show_Invalid(self):
94 111
         req = fakes.HTTPRequest.blank('/v1/verifications/1')

Loading…
Cancel
Save