[SEBA-497]
Change to using alpine-grpc-base
Fix issue with nested exceptions causing an error in structlog
Reformat and python3 fixes, v3.5 mock support
Record execution times in the loader
Change-Id: I6d7923818d57012fca32ce44668820de422206d6
diff --git a/test/test_tosca_generator.py b/test/test_tosca_generator.py
index f76dce5..871ca18 100644
--- a/test/test_tosca_generator.py
+++ b/test/test_tosca_generator.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,38 +12,55 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from helpers import *
+from __future__ import absolute_import
+from __future__ import print_function
+from . import helpers # noqa: F401
import unittest
import os
from xosgenx.generator import XOSProcessor, XOSProcessorArgs
current_dir = os.path.dirname(os.path.realpath(__file__))
-OUTPUT_DIR = os.path.join(current_dir, 'out');
-print OUTPUT_DIR
+OUTPUT_DIR = os.path.join(current_dir, "out")
+print(OUTPUT_DIR)
+
class TOSCA_Generator_Test(unittest.TestCase):
-
def test_generate_basic_tosca(self):
"""
[TOSCA_xtarget] Should generate a basic TOSCA recipe
"""
- xproto = \
- """
+ xproto = """
option app_label = "core";
message XOSGuiExtension (XOSBase) {
option verbose_name="XOS GUI Extension";
option description="This model holds the instruction to load an extension in the GUI";
- required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the GUI Extensions", null = False, db_index = False];
- required string files = 2 [max_length = 1024, content_type = "stripped", blank = False, help_text = "List of comma separated file composing the view", null = False, db_index = False];
+ required string name = 1 [
+ max_length = 200,
+ content_type = "stripped",
+ blank = False,
+ help_text = "Name of the GUI Extensions",
+ null = False,
+ db_index = False
+ ];
+ required string files = 2 [
+ max_length = 1024,
+ content_type = "stripped",
+ blank = False,
+ help_text = "List of comma separated file composing the view",
+ null = False,
+ db_index = False
+ ];
}
"""
- args = XOSProcessorArgs(inputs = xproto,
- target = os.path.join(current_dir, '../src/tosca/xtarget/tosca.xtarget'),
- output = OUTPUT_DIR,
- write_to_file = "single",
- dest_file = "basic.yaml",
- quiet = False)
+ args = XOSProcessorArgs(
+ inputs=xproto,
+ target=os.path.join(current_dir, "../src/tosca/xtarget/tosca.xtarget"),
+ output=OUTPUT_DIR,
+ write_to_file="single",
+ dest_file="basic.yaml",
+ quiet=False,
+ )
output = XOSProcessor.process(args)
self.assertIn("name:", output)
self.assertIn("files:", output)
@@ -53,28 +69,42 @@
"""
[TOSCA_xtarget] Should generate a TOSCA recipe for a models that inherits from another model
"""
- xproto = \
- """
+ xproto = """
option app_label = "core";
message Service (XosBase) {
option verbose_name="Basic Service";
- required string name = 1 [max_length = 200, content_type = "stripped", blank = False, null = False, db_index = False];
+ required string name = 1 [
+ max_length = 200,
+ content_type = "stripped",
+ blank = False,
+ null = False,
+ db_index = False
+ ];
}
-
+
message MyService (Service) {
option verbose_name="Extending service";
- required string prop = 1 [max_length = 200, content_type = "stripped", blank = False, null = False, db_index = False];
+ required string prop = 1 [
+ max_length = 200,
+ content_type = "stripped",
+ blank = False,
+ null = False,
+ db_index = False
+ ];
}
"""
- args = XOSProcessorArgs(inputs = xproto,
- target = os.path.join(current_dir, '../src/tosca/xtarget/tosca.xtarget'),
- output = OUTPUT_DIR,
- write_to_file = 'target',
- quiet = False)
+ args = XOSProcessorArgs(
+ inputs=xproto,
+ target=os.path.join(current_dir, "../src/tosca/xtarget/tosca.xtarget"),
+ output=OUTPUT_DIR,
+ write_to_file="target",
+ quiet=False,
+ )
output = XOSProcessor.process(args)
self.assertEqual(output.count("name:"), 4)
self.assertIn("prop:", output)
-if __name__ == '__main__':
- unittest.main()
+
+if __name__ == "__main__":
+ unittest.main()