summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuanliu <yuanliu@cmss.chinamobile.com>2018-11-30 12:52:14 +0800
committeryuanliu <yuanliu@cmss.chinamobile.com>2018-11-30 14:34:07 +0800
commitc74b622ff77a3cdf1dfabe34919174391c4a0d95 (patch)
treecab85b64d8adec434c5e32328709c167ac07f54e
parent6deaf213dc4a55072d7c2b12d74e65fa180ecdb3 (diff)
add a unitest for api of verification
Notes
Notes (review): Code-Review+1: Gaƫtan Trellu <gaetan.trellu@incloudus.com> 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: Sun, 02 Dec 2018 06:18:09 +0000 Reviewed-on: https://review.openstack.org/621070 Project: openstack/karbor Branch: refs/heads/master
-rwxr-xr-x[-rw-r--r--]karbor/tests/unit/api/v1/test_verifications.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/karbor/tests/unit/api/v1/test_verifications.py b/karbor/tests/unit/api/v1/test_verifications.py
index 39a05fa..ba892da 100644..100755
--- a/karbor/tests/unit/api/v1/test_verifications.py
+++ b/karbor/tests/unit/api/v1/test_verifications.py
@@ -76,19 +76,36 @@ class VerificationApiTest(base.TestCase):
76 @mock.patch( 76 @mock.patch(
77 'karbor.api.v1.verifications.' 77 'karbor.api.v1.verifications.'
78 'VerificationsController._get_all') 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 req = fakes.HTTPRequest.blank('/v1/verifications') 80 req = fakes.HTTPRequest.blank('/v1/verifications')
81 self.controller.index(req) 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 @mock.patch( 101 @mock.patch(
85 'karbor.api.v1.verifications.' 102 'karbor.api.v1.verifications.'
86 'VerificationsController._verification_get') 103 'VerificationsController._verification_get')
87 def test_verification_show(self, moak_verification_get): 104 def test_verification_show(self, mock_verification_get):
88 req = fakes.HTTPRequest.blank('/v1/verifications') 105 req = fakes.HTTPRequest.blank('/v1/verifications')
89 self.controller.show( 106 self.controller.show(
90 req, '2a9ce1f3-cc1a-4516-9435-0ebb13caa398') 107 req, '2a9ce1f3-cc1a-4516-9435-0ebb13caa398')
91 self.assertTrue(moak_verification_get.called) 108 self.assertTrue(mock_verification_get.called)
92 109
93 def test_verification_show_Invalid(self): 110 def test_verification_show_Invalid(self):
94 req = fakes.HTTPRequest.blank('/v1/verifications/1') 111 req = fakes.HTTPRequest.blank('/v1/verifications/1')