[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_jinja2_django.py b/lib/xos-genx/xos-genx-tests/test_jinja2_django.py
index ab47443..108ae4e 100644
--- a/lib/xos-genx/xos-genx-tests/test_jinja2_django.py
+++ b/lib/xos-genx/xos-genx-tests/test_jinja2_django.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,103 +16,70 @@
import unittest
from xosgenx.jinja2_extensions.django import *
+
class Jinja2BaseTests(unittest.TestCase):
def test_xproto_optioned_fields_to_list(self):
fields = [
- {
- 'name': 'has_feedback_1',
- 'options': {
- 'feedback_state': 'True',
- }
- },
- {
- 'name': 'has_feedback_2',
- 'options': {
- 'feedback_state': 'True',
- }
- },
- {
- 'name': 'no_feedback',
- 'options': {
- 'feedback_state': 'False',
- }
- }
+ {"name": "has_feedback_1", "options": {"feedback_state": "True"}},
+ {"name": "has_feedback_2", "options": {"feedback_state": "True"}},
+ {"name": "no_feedback", "options": {"feedback_state": "False"}},
]
- res = xproto_optioned_fields_to_list(fields, 'feedback_state', 'True')
+ res = xproto_optioned_fields_to_list(fields, "feedback_state", "True")
self.assertEqual(res, ["has_feedback_1", "has_feedback_2"])
def test_xproto_required_to_django(self):
- field = {
- 'name': 'foo',
- 'options': {
- 'modifier': 'required'
- }
- }
+ field = {"name": "foo", "options": {"modifier": "required"}}
res = map_xproto_to_django(field)
- self.assertEqual(res, {'blank': False, 'null': False})
+ self.assertEqual(res, {"blank": False, "null": False})
def test_xproto_optional_to_django(self):
- field = {
- 'name': 'foo',
- 'options': {
- 'modifier': 'optional'
- }
- }
+ field = {"name": "foo", "options": {"modifier": "optional"}}
res = map_xproto_to_django(field)
- self.assertEqual(res, {'blank': True, 'null': True})
-
+ self.assertEqual(res, {"blank": True, "null": True})
def test_map_xproto_to_django(self):
options = {
- 'help_text': 'bar',
- 'default': 'default_value',
- 'null': True,
- 'db_index': False,
- 'blank': False,
- 'min_value': 16,
- 'max_value': 16
+ "help_text": "bar",
+ "default": "default_value",
+ "null": True,
+ "db_index": False,
+ "blank": False,
+ "min_value": 16,
+ "max_value": 16,
}
- field = {
- 'name': 'foo',
- 'options': options
- }
+ field = {"name": "foo", "options": options}
res = map_xproto_to_django(field)
self.assertEqual(res, options)
def test_format_options_string(self):
- options = {
- 'null': True,
- 'min_value': 16,
- 'max_value': 16
- }
+ options = {"null": True, "min_value": 16, "max_value": 16}
res = format_options_string(options)
- self.assertEqual(res, "null = True, validators=[MaxValueValidator(16), MinValueValidator(16)]")
+ self.assertEqual(
+ res,
+ "null = True, validators=[MaxValueValidator(16), MinValueValidator(16)]",
+ )
- options = {
- 'min_value': 16,
- 'max_value': 16
- }
+ options = {"min_value": 16, "max_value": 16}
res = format_options_string(options)
- self.assertEqual(res, "validators=[MaxValueValidator(16), MinValueValidator(16)]")
+ self.assertEqual(
+ res, "validators=[MaxValueValidator(16), MinValueValidator(16)]"
+ )
- options = {
- 'null': True,
- }
+ options = {"null": True}
res = format_options_string(options)
self.assertEqual(res, "null = True")
-if __name__ == '__main__':
+
+if __name__ == "__main__":
unittest.main()
-
-