summaryrefslogtreecommitdiff
path: root/barbicanclient/test/test_client_verifications.py
diff options
context:
space:
mode:
Diffstat (limited to 'barbicanclient/test/test_client_verifications.py')
-rw-r--r--barbicanclient/test/test_client_verifications.py97
1 files changed, 65 insertions, 32 deletions
diff --git a/barbicanclient/test/test_client_verifications.py b/barbicanclient/test/test_client_verifications.py
index c72120f..d7f3b8f 100644
--- a/barbicanclient/test/test_client_verifications.py
+++ b/barbicanclient/test/test_client_verifications.py
@@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from barbicanclient import verifications as verify
+from barbicanclient import verifications as vers
from barbicanclient.openstack.common import timeutils
from barbicanclient.test import test_client
-from barbicanclient.test import test_client_secrets as test_secrets
class VerificationData(object):
@@ -41,14 +40,27 @@ class VerificationData(object):
return verify
-class WhenTestingVerificationsManager(test_client.BaseEntityResource):
+class WhenTestingVerifications(test_client.BaseEntityResource):
def setUp(self):
self._setUp('verifications')
self.verify = VerificationData()
- self.manager = verify.VerificationManager(self.api)
+ self.manager = vers.VerificationManager(self.api)
+
+ def test_should_entity_str(self):
+ verif_obj = vers.Verification(self.verify.get_dict(self.entity_href))
+ verif_obj.error_status_code = '500'
+ verif_obj.error_reason = 'Something is broken'
+ self.assertIn('resource_type: ' + self.verify.resource_type,
+ str(verif_obj))
+ self.assertIn('error_status_code: 500', str(verif_obj))
+
+ def test_should_entity_repr(self):
+ verif = vers.Verification(self.verify.get_dict(self.entity_href))
+ self.assertIn('verification_ref=' + self.entity_href,
+ repr(verif))
def test_should_create(self):
self.api.post.return_value = {'verification_ref': self.entity_href}
@@ -67,36 +79,57 @@ class WhenTestingVerificationsManager(test_client.BaseEntityResource):
# Verify that correct information was sent in the call.
verify_req = args[1]
- self.assertEqual(self.verify.resource_type, verify_req['resource_type'])
+ self.assertEqual(self.verify.resource_type,
+ verify_req['resource_type'])
self.assertEqual(self.verify.resource_action,
verify_req['resource_action'])
self.assertEqual(self.verify.resource_ref,
verify_req['resource_ref'])
- # def test_should_get(self):
- # self.api.get.return_value = self.order.get_dict(self.entity_href)
- #
- # order = self.manager.get(order_ref=self.entity_href)
- # self.assertIsInstance(order, orders.Order)
- # self.assertEqual(self.entity_href, order.order_ref)
- #
- # # Verify the correct URL was used to make the call.
- # args, kwargs = self.api.get.call_args
- # url = args[0]
- # self.assertEqual(self.entity_href, url)
- #
- # def test_should_delete(self):
- # self.manager.delete(order_ref=self.entity_href)
- #
- # # Verify the correct URL was used to make the call.
- # args, kwargs = self.api.delete.call_args
- # url = args[0]
- # self.assertEqual(self.entity_href, url)
- #
- # def test_should_fail_get_no_href(self):
- # with self.assertRaises(ValueError):
- # self.manager.get(None)
- #
- # def test_should_fail_delete_no_href(self):
- # with self.assertRaises(ValueError):
- # self.manager.delete(None)
+ def test_should_get(self):
+ self.api.get.return_value = self.verify.get_dict(self.entity_href)
+
+ verify = self.manager.get(verification_ref=self.entity_href)
+ self.assertIsInstance(verify, vers.Verification)
+ self.assertEqual(self.entity_href, verify.verif_ref)
+
+ # Verify the correct URL was used to make the call.
+ args, kwargs = self.api.get.call_args
+ url = args[0]
+ self.assertEqual(self.entity_href, url)
+
+ def test_should_delete(self):
+ self.manager.delete(verification_ref=self.entity_href)
+
+ # Verify the correct URL was used to make the call.
+ args, kwargs = self.api.delete.call_args
+ url = args[0]
+ self.assertEqual(self.entity_href, url)
+
+ def test_should_get_list(self):
+ verify_resp = self.verify.get_dict(self.entity_href)
+ self.api.get.return_value = {"verifications":
+ [verify_resp for v in xrange(3)]}
+
+ verifies = self.manager.list(limit=10, offset=5)
+ self.assertTrue(len(verifies) == 3)
+ self.assertIsInstance(verifies[0], vers.Verification)
+ self.assertEqual(self.entity_href, verifies[0].verif_ref)
+
+ # Verify the correct URL was used to make the call.
+ args, kwargs = self.api.get.call_args
+ url = args[0]
+ self.assertEqual(self.entity_base[:-1], url)
+
+ # Verify that correct information was sent in the call.
+ params = args[1]
+ self.assertEqual(10, params['limit'])
+ self.assertEqual(5, params['offset'])
+
+ def test_should_fail_get_no_href(self):
+ with self.assertRaises(ValueError):
+ self.manager.get(None)
+
+ def test_should_fail_delete_no_href(self):
+ with self.assertRaises(ValueError):
+ self.manager.delete(None)