summaryrefslogtreecommitdiff
path: root/barbicanclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-07 17:34:12 +0000
committerGerrit Code Review <review@openstack.org>2017-04-07 17:34:12 +0000
commit876d0c854a2f22271caa1cc0b7b3a226a4590079 (patch)
tree2625544c76006d55d94626f003dbadc5a57c4955 /barbicanclient/tests
parent978d3b43f3feac5a6013a1deec3db290fef71225 (diff)
parent15bba221e9b343d79c6d50e9b9d264af402898cf (diff)
downloadpython-barbicanclient-876d0c854a2f22271caa1cc0b7b3a226a4590079.tar.gz
Merge "Enable F and H flake8 rules"
Diffstat (limited to 'barbicanclient/tests')
-rw-r--r--barbicanclient/tests/test_barbican.py5
-rw-r--r--barbicanclient/tests/test_base.py15
-rw-r--r--barbicanclient/tests/test_cas.py2
-rw-r--r--barbicanclient/tests/test_containers.py4
-rw-r--r--barbicanclient/tests/test_formatter.py15
-rw-r--r--barbicanclient/tests/test_orders.py17
-rw-r--r--barbicanclient/tests/test_secrets.py37
7 files changed, 62 insertions, 33 deletions
diff --git a/barbicanclient/tests/test_barbican.py b/barbicanclient/tests/test_barbican.py
index 0e5bd30..6f4e966 100644
--- a/barbicanclient/tests/test_barbican.py
+++ b/barbicanclient/tests/test_barbican.py
@@ -14,11 +14,11 @@
# limitations under the License.
import six
-from barbicanclient import client
from barbicanclient import barbican as barb
+from barbicanclient.barbican import Barbican
+from barbicanclient import client
from barbicanclient.tests import keystone_client_fixtures
from barbicanclient.tests import test_client
-from barbicanclient.barbican import Barbican
class WhenTestingBarbicanCLI(test_client.BaseEntityResource):
@@ -171,7 +171,6 @@ class WhenTestingBarbicanCLI(test_client.BaseEntityResource):
self.assertIsNone(httpclient.service_name)
def test_endpoint_filter_kwargs_set_correctly(self):
- from testtools.content import text_content
auth_args = ('--no-auth --endpoint http://barbican_endpoint:9311/v1 '
'--os-project-id project1')
endpoint_filter_args = ('--interface private '
diff --git a/barbicanclient/tests/test_base.py b/barbicanclient/tests/test_base.py
index cb75c2d..6f0fa8c 100644
--- a/barbicanclient/tests/test_base.py
+++ b/barbicanclient/tests/test_base.py
@@ -1,3 +1,18 @@
+# Copyright (c) 2017
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import testtools
import barbicanclient
diff --git a/barbicanclient/tests/test_cas.py b/barbicanclient/tests/test_cas.py
index 86ac118..c28f38f 100644
--- a/barbicanclient/tests/test_cas.py
+++ b/barbicanclient/tests/test_cas.py
@@ -14,8 +14,8 @@
# limitations under the License.
from oslo_utils import timeutils
-from barbicanclient.tests import test_client
from barbicanclient import cas
+from barbicanclient.tests import test_client
class CAData(object):
diff --git a/barbicanclient/tests/test_containers.py b/barbicanclient/tests/test_containers.py
index 6441c23..6d967c7 100644
--- a/barbicanclient/tests/test_containers.py
+++ b/barbicanclient/tests/test_containers.py
@@ -20,8 +20,10 @@ from oslo_utils import timeutils
import six
from barbicanclient import acls
+from barbicanclient import base
+from barbicanclient import containers
+from barbicanclient import secrets
from barbicanclient.tests import test_client
-from barbicanclient import base, containers, secrets
class ContainerData(object):
diff --git a/barbicanclient/tests/test_formatter.py b/barbicanclient/tests/test_formatter.py
index 94f3752..a09b1b6 100644
--- a/barbicanclient/tests/test_formatter.py
+++ b/barbicanclient/tests/test_formatter.py
@@ -1,3 +1,18 @@
+# Copyright (c) 2017
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import testtools
from barbicanclient import formatter
diff --git a/barbicanclient/tests/test_orders.py b/barbicanclient/tests/test_orders.py
index 21eee98..2ae4913 100644
--- a/barbicanclient/tests/test_orders.py
+++ b/barbicanclient/tests/test_orders.py
@@ -14,14 +14,12 @@
# limitations under the License.
import json
-import mock
from oslo_utils import timeutils
-import testtools
import uuid
-from barbicanclient import orders, base
+from barbicanclient import base
+from barbicanclient import orders
from barbicanclient.tests import test_client
-from barbicanclient.tests import test_secrets
class OrdersTestCase(test_client.BaseEntityResource):
@@ -280,12 +278,10 @@ class WhenTestingOrderManager(OrdersTestCase):
def test_should_get_invalid_meta(self):
self.responses.get(self.entity_href, text=self.key_order_invalid_data)
- try:
- # Verify checking for invalid meta fields.
- order = self.manager.get(order_ref=self.entity_href)
- self.fail("Didn't raise an TypeError exception")
- except TypeError:
- pass
+ # Verify checking for invalid meta fields.
+ self.assertRaises(TypeError,
+ self.manager.get,
+ self.entity_href)
def test_should_get_list(self):
data = {"orders": [json.loads(self.key_order_data) for _ in range(3)]}
@@ -318,6 +314,7 @@ class WhenTestingOrderManager(OrdersTestCase):
def test_should_get_total(self):
self.responses.get(self.entity_base, json={'total': 1})
total = self.manager.total()
+ self.assertEqual(1, total)
def test_get_formatted_data(self):
self.responses.get(self.entity_href, text=self.key_order_data)
diff --git a/barbicanclient/tests/test_secrets.py b/barbicanclient/tests/test_secrets.py
index 61efdb0..0cd981c 100644
--- a/barbicanclient/tests/test_secrets.py
+++ b/barbicanclient/tests/test_secrets.py
@@ -17,9 +17,11 @@ import json
from oslo_utils import timeutils
-from barbicanclient.tests import test_client
from barbicanclient import acls
-from barbicanclient import secrets, base, exceptions
+from barbicanclient import base
+from barbicanclient import exceptions
+from barbicanclient import secrets
+from barbicanclient.tests import test_client
class SecretData(object):
@@ -90,8 +92,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
self.assertEqual(self.secret.payload, secret_req['payload'])
def test_should_store_binary_type_as_octet_stream(self):
- """
- We use six.binary_type as the canonical binary type.
+ """We use six.binary_type as the canonical binary type.
+
The client should base64 encode the payload before sending the
request.
"""
@@ -116,9 +118,7 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
self.assertNotEqual(binary_payload, secret_req['payload'])
def test_should_store_text_type_as_text_plain(self):
- """
- We use six.text_type as the canonical text type.
- """
+ """We use six.text_type as the canonical text type."""
data = {'secret_ref': self.entity_href}
self.responses.post(self.entity_base + '/', json=data)
@@ -135,8 +135,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
self.assertEqual(u'text/plain', secret_req['payload_content_type'])
def test_should_store_with_deprecated_content_type(self):
- """
- DEPRECATION WARNING:
+ """DEPRECATION WARNING
+
Manually setting the payload_content_type is deprecated and will be
removed in a future release.
"""
@@ -157,8 +157,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
secret_req['payload_content_type'])
def test_should_store_with_deprecated_content_encoding(self):
- """
- DEPRECATION WARNING:
+ """DEPRECATION WARNING
+
Manually setting the payload_content_encoding is deprecated and will be
removed in a future release.
"""
@@ -261,8 +261,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
self.assertEqual(acl_ref, n.last_request.url)
def test_should_get_payload_only_when_content_type_is_set(self):
- """
- DEPRECATION WARNING:
+ """DEPRECATION WARNING
+
Manually setting the payload_content_type is deprecated and will be
removed in a future release.
"""
@@ -339,8 +339,8 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
decryption_response.last_request.url)
def test_should_decrypt_when_content_type_is_set(self):
- """
- DEPRECATION WARNING:
+ """DEPRECATION WARNING
+
Manually setting the payload_content_type is deprecated and will be
removed in a future release.
"""
@@ -491,9 +491,10 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
def test_get_formatted_data(self):
data = self.secret.get_dict(self.entity_href)
- m = self.responses.get(self.entity_href, json=data)
+ self.responses.get(self.entity_href, json=data)
secret = self.manager.get(secret_ref=self.entity_href)
f_data = secret._get_formatted_data()
- self.assertEqual(timeutils.parse_isotime(data['created']).isoformat(),
- f_data[2])
+ self.assertEqual(
+ timeutils.parse_isotime(data['created']).isoformat(),
+ f_data[2])