summaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2017-07-17 08:54:22 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2017-08-01 11:13:58 +0800
commit9549a92ad62fbbad00e355b707809e6409b9e085 (patch)
tree9b7052325ca7fd067648ef9879d6cab46fa2f2c9 /tests/utils.py
parent162c3ae179f69bd326325b135c3831ae12843e49 (diff)
refactor local installer
JIRA: DOCTOR-100 Change-Id: I1e2c53f7a716156e35386d42c0df32a228a78fab Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py
new file mode 100644
index 00000000..c5d6c1c3
--- /dev/null
+++ b/tests/utils.py
@@ -0,0 +1,33 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import json
+import os
+
+
+def load_json_file(full_path):
+ """Loads JSON from file
+ :param target_filename:
+ :return:
+ """
+ if not os.path.isfile(full_path):
+ raise Exception('File(%s) does not exist' % full_path)
+
+ with open(full_path, 'r') as file:
+ return json.load(file)
+
+
+def write_json_file(full_path, data):
+ """write JSON from file
+ :param target_filename:
+ :return:
+ """
+
+ with open(full_path, 'w+') as file:
+ file.write(json.dumps(data))
+