[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_django_generator.py b/lib/xos-genx/xos-genx-tests/test_django_generator.py
index 4f4dae4..a81f80c 100644
--- a/lib/xos-genx/xos-genx-tests/test_django_generator.py
+++ b/lib/xos-genx/xos-genx-tests/test_django_generator.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,34 +17,36 @@
import os
from xosgenx.generator import XOSProcessor, XOSProcessorArgs
-VROUTER_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/vrouterport.xproto")
+VROUTER_XPROTO = os.path.abspath(
+ os.path.dirname(os.path.realpath(__file__)) + "/xproto/vrouterport.xproto"
+)
# Generate Protobuf from Xproto and then parse the resulting Protobuf
+
+
class XProtoProtobufGeneratorTest(unittest.TestCase):
def test_proto_generator(self):
"""
[XOS-GenX] Generate DJANGO models, verify Fields and Foreign Keys
"""
- args = XOSProcessorArgs(files = [VROUTER_XPROTO],
- target = 'django.xtarget')
+ args = XOSProcessorArgs(files=[VROUTER_XPROTO], target="django.xtarget")
output = XOSProcessor.process(args)
- fields = filter(lambda s:'Field(' in s, output.splitlines())
+ fields = filter(lambda s: "Field(" in s, output.splitlines())
self.assertEqual(len(fields), 2)
- links = filter(lambda s:'Key(' in s, output.splitlines())
+ links = filter(lambda s: "Key(" in s, output.splitlines())
self.assertEqual(len(links), 2)
def test_optional_relations(self):
"""
[XOS-GenX] Generate DJANGO models, verify relations
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message ENodeB {
}
-
+
message Handover {
}
@@ -55,15 +56,14 @@
}
"""
- args = XOSProcessorArgs(inputs = xproto,
- target = 'django.xtarget')
+ args = XOSProcessorArgs(inputs=xproto, target="django.xtarget")
output = XOSProcessor.process(args)
- null_true = filter(lambda s: 'null = True' in s, output.splitlines())
- null_false = filter(lambda s: 'null = False' in s, output.splitlines())
+ null_true = filter(lambda s: "null = True" in s, output.splitlines())
+ null_false = filter(lambda s: "null = False" in s, output.splitlines())
- blank_true = filter(lambda s: 'blank = True' in s, output.splitlines())
- blank_false = filter(lambda s: 'blank = False' in s, output.splitlines())
+ blank_true = filter(lambda s: "blank = True" in s, output.splitlines())
+ blank_false = filter(lambda s: "blank = False" in s, output.splitlines())
self.assertEqual(len(null_true), 1)
self.assertEqual(len(null_false), 1)
@@ -74,8 +74,7 @@
"""
[XOS-GenX] Generate DJANGO models, verify feedback_state fields
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message ParentFoo {
@@ -87,8 +86,7 @@
}
"""
- args = XOSProcessorArgs(inputs = xproto,
- target = 'django.xtarget')
+ args = XOSProcessorArgs(inputs=xproto, target="django.xtarget")
output = XOSProcessor.process(args)
self.assertIn("feedback_state_fields = ['parent_name', 'name']", output)
@@ -97,8 +95,7 @@
"""
[XOS-GenX] Use django validors for min and max values
"""
- xproto = \
- """
+ xproto = """
option app_label = "test";
message Foo (ParentFoo) {
@@ -106,15 +103,13 @@
}
"""
- args = XOSProcessorArgs(inputs = xproto,
- target = 'django.xtarget')
+ args = XOSProcessorArgs(inputs=xproto, target="django.xtarget")
output = XOSProcessor.process(args)
self.assertIn("validators=[", output)
self.assertIn("MinValueValidator(1)", output)
self.assertIn("MaxValueValidator(10)", output)
-if __name__ == '__main__':
+
+if __name__ == "__main__":
unittest.main()
-
-