aboutsummaryrefslogtreecommitdiffstats
path: root/tests/usecases/5G-bulkpm/resources
diff options
context:
space:
mode:
authorLiamBurke <Liam.Burke@ericsson.com>2019-02-14 13:24:52 +0000
committerLiamBurke <liam.burke@ericsson.com>2019-02-14 14:35:26 +0000
commit4d438ce1f40fe4cf2632a7bdb5ee72910f5f8037 (patch)
tree1566c3dfd52e71df0821a2fe3f59317870de6652 /tests/usecases/5G-bulkpm/resources
parentfd967387f666cdf7f7e57c7ee7ac4947c0dd0535 (diff)
BulkPM Add Metadata Test Case
Change-Id: Ieb5709f6b223579baca402322f7a9fec1daa1a73 Issue-ID: INT-832 Signed-off-by: LiamBurke <liam.burke@ericsson.com>
Diffstat (limited to 'tests/usecases/5G-bulkpm/resources')
-rw-r--r--tests/usecases/5G-bulkpm/resources/JsonValidatorLibrary.py38
-rw-r--r--tests/usecases/5G-bulkpm/resources/bulkpm_keywords.robot1
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/usecases/5G-bulkpm/resources/JsonValidatorLibrary.py b/tests/usecases/5G-bulkpm/resources/JsonValidatorLibrary.py
new file mode 100644
index 00000000..12d5d856
--- /dev/null
+++ b/tests/usecases/5G-bulkpm/resources/JsonValidatorLibrary.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import logging
+from simplejson import load
+from jsonschema import validate, ValidationError, SchemaError
+
+
+class JsonValidatorLibrary(object):
+
+ def __init__(self):
+ pass
+
+ def validate(self, schemaPath, jsonPath):
+ logging.info("Schema path: " + schemaPath)
+ logging.info("JSON path: " + jsonPath)
+ schema = None
+ data = None
+ try:
+ schema = load(open(schemaPath, 'r'))
+ data = load(open(jsonPath, 'r'))
+ except (IOError, ValueError, OSError) as e:
+ logging.error(e.message)
+ return 1
+
+ try:
+ validate(data, schema)
+ except (ValidationError, SchemaError) as e:
+ logging.error(e.message)
+ return 1
+
+ # logger.log("JSON validation successful")
+ print("JSON validation successful")
+ return 0
+
+if __name__ == '__main__':
+ lib = JsonValidatorLibrary()
+ # sys.exit(JsonValidatorLibrary().validate(sys.argv[1], sys.argv[2]))
diff --git a/tests/usecases/5G-bulkpm/resources/bulkpm_keywords.robot b/tests/usecases/5G-bulkpm/resources/bulkpm_keywords.robot
index 6859ea0d..9ef56c83 100644
--- a/tests/usecases/5G-bulkpm/resources/bulkpm_keywords.robot
+++ b/tests/usecases/5G-bulkpm/resources/bulkpm_keywords.robot
@@ -2,6 +2,7 @@
Documentation The main interface for interacting with VES. It handles low level stuff like managing the http request library and VES required fields
Library RequestsLibrary
Library ../resources/xNFLibrary.py
+Library ../resources/JsonValidatorLibrary.py
Library OperatingSystem
Library Collections
Library requests