[SEBA-412] Automated reformat of Python code
Passes of modernize, autopep8, black, then check with flake8
flake8 + manual fixes:
lib/xos-config
lib/xos-kafka
lib/xos-util
xos/coreapi
xos/api
xos/xos_client
Change-Id: Ib23cf84cb13beb3c6381fa0d79594dc9131dc815
diff --git a/lib/xos-genx/xos-genx-tests/test_tosca.py b/lib/xos-genx/xos-genx-tests/test_tosca.py
index 270d126..c5a0f17 100644
--- a/lib/xos-genx/xos-genx-tests/test_tosca.py
+++ b/lib/xos-genx/xos-genx-tests/test_tosca.py
@@ -18,7 +18,6 @@
class XProtoToscaTypeTest(unittest.TestCase):
-
def setUp(self):
self.target_tosca_type = XProtoTestHelpers.write_tmp_target(
"""
@@ -27,13 +26,14 @@
{{ xproto_tosca_field_type(f.type) }}
{% endfor -%}
{% endfor -%}
- """)
+ """
+ )
+
def test_tosca_fields(self):
"""
[XOS-GenX] should convert xproto types to tosca know types
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message Foo {
@@ -47,26 +47,26 @@
args.inputs = xproto
args.target = self.target_tosca_type
output = XOSProcessor.process(args)
- self.assertIn('string', output)
- self.assertIn('boolean', output)
- self.assertIn('integer', output)
+ self.assertIn("string", output)
+ self.assertIn("boolean", output)
+ self.assertIn("integer", output)
+
class XProtoToscaKeyTest(unittest.TestCase):
-
def setUp(self):
self.target_tosca_keys = XProtoTestHelpers.write_tmp_target(
"""
{%- for m in proto.messages %}
{{ xproto_fields_to_tosca_keys(m.fields, m) }}
{% endfor -%}
- """)
+ """
+ )
def test_xproto_fields_to_tosca_keys_default(self):
"""
[XOS-GenX] if no "tosca_key" is specified, and a name attribute is present in the model, use that
"""
- xproto = \
-"""
+ xproto = """
option app_label = "test";
message Foo {
@@ -78,16 +78,15 @@
args.inputs = xproto
args.target = self.target_tosca_keys
output = XOSProcessor.process(args)
- self.assertIn('name', output)
+ self.assertIn("name", output)
def test_xproto_fields_to_tosca_keys_custom(self):
"""
[XOS-GenX] if "tosca_key" is specified, use it
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
-
+
message Foo {
required string name = 1 [ null = "False", blank="False"];
required string key_1 = 2 [ null = "False", blank="False", tosca_key=True];
@@ -99,16 +98,15 @@
args.inputs = xproto
args.target = self.target_tosca_keys
output = XOSProcessor.process(args)
- self.assertNotIn('name', output)
- self.assertIn('key_1', output)
- self.assertIn('key_2', output)
+ self.assertNotIn("name", output)
+ self.assertIn("key_1", output)
+ self.assertIn("key_2", output)
def test_xproto_fields_link_to_tosca_keys_custom(self):
"""
[XOS-GenX] if "tosca_key" is specified, use it
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message Foo {
@@ -121,21 +119,20 @@
args.inputs = xproto
args.target = self.target_tosca_keys
output = XOSProcessor.process(args)
- self.assertNotIn('name', output)
- self.assertIn('provider_service_instance_id', output)
+ self.assertNotIn("name", output)
+ self.assertIn("provider_service_instance_id", output)
def test_xproto_model_to_oneof_key(self):
"""
[XOS-GenX] in some models we need to have a combine key on variable fields, for example, keys can be subscriber_service_id + oneof(provider_service_id, provider_network_id)
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message Foo {
-
+
option tosca_key = "key1, oneof(key_2, key_3)";
-
+
required string name = 1 [ null = "False", blank="False"];
required string key_1 = 2 [ null = "False", blank="False", tosca_key_one_of = "key_2"];
required string key_2 = 3 [ null = "False", blank="False", tosca_key_one_of = "key_1"];
@@ -150,8 +147,7 @@
output = XOSProcessor.process(args)
self.assertIn("['name', ['key_4', 'key_3'], ['key_1', 'key_2']]", output)
- xproto = \
- """
+ xproto = """
option app_label = "test";
message Foo {