[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_field_graph.py b/lib/xos-genx/xos-genx-tests/test_field_graph.py
index 478708a..cfb4c8b 100644
--- a/lib/xos-genx/xos-genx-tests/test_field_graph.py
+++ b/lib/xos-genx/xos-genx-tests/test_field_graph.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,11 +17,12 @@
from xosgenx.jinja2_extensions import FieldNotFound
from helpers import XProtoTestHelpers
from xosgenx.generator import XOSProcessor, XOSProcessorArgs
+from functools import reduce
+
class XProtoFieldGraphTest(unittest.TestCase):
def _test_field_graph(self):
- xproto = \
-"""
+ xproto = """
message VRouterDevice (PlCoreBase){
optional string name = 1 [help_text = "device friendly name", max_length = 20, null = True, db_index = False, blank = True, unique_with="openflow_id"];
required string openflow_id = 2 [help_text = "device identifier in ONOS", max_length = 20, null = False, db_index = False, blank = False, unique_with="name"];
@@ -39,45 +39,46 @@
}
"""
target = XProtoTestHelpers.write_tmp_target(
-"""
+ """
{{ xproto_field_graph_components(proto.messages.0.fields, proto.messages.0) }}
-""")
+"""
+ )
- args = XOSProcessorArgs(inputs = xproto,
- target = target)
+ args = XOSProcessorArgs(inputs=xproto, target=target)
output = XOSProcessor.process(args)
- output = eval(output)
- self.assertIn({'A','B','C'}, output)
- self.assertIn({'openflow_id','name'}, output)
- self.assertIn({'config_key','vrouter_service','driver'}, output)
- self.assertIn({'E','F','G'}, output)
-
- union = reduce(lambda acc,x: acc | x, output)
- self.assertNotIn('D', union)
+ output = eval(output)
+ self.assertIn({"A", "B", "C"}, output)
+ self.assertIn({"openflow_id", "name"}, output)
+ self.assertIn({"config_key", "vrouter_service", "driver"}, output)
+ self.assertIn({"E", "F", "G"}, output)
+
+ union = reduce(lambda acc, x: acc | x, output)
+ self.assertNotIn("D", union)
def test_missing_field(self):
- xproto = \
-"""
+ xproto = """
message Foo (PlCoreBase){
required string A = 6 [unique_with="B"];
}
"""
target = XProtoTestHelpers.write_tmp_target(
-"""
+ """
{{ xproto_field_graph_components(proto.messages.0.fields, proto.messages.0) }}
-""")
+"""
+ )
def generate():
- args = XOSProcessorArgs(inputs = xproto,
- target = target)
+ args = XOSProcessorArgs(inputs=xproto, target=target)
output = XOSProcessor.process(args)
with self.assertRaises(FieldNotFound) as e:
- generate()
+ generate()
- self.assertEqual(e.exception.message, 'Field "B" not found in model "Foo", referenced from field "A" by option "unique_with"')
+ self.assertEqual(
+ e.exception.message,
+ 'Field "B" not found in model "Foo", referenced from field "A" by option "unique_with"',
+ )
-if __name__ == '__main__':
+
+if __name__ == "__main__":
unittest.main()
-
-