summaryrefslogtreecommitdiffstats
path: root/dovetail/tests/unit/test_report.py
diff options
context:
space:
mode:
authorStamatis Katsaounis <mokats@intracom-telecom.com>2019-02-19 12:38:10 +0200
committerDan Xu <xudan16@huawei.com>2019-03-13 10:48:45 +0000
commitb4e6a756ebeb019048cb03a0562534870b772cae (patch)
tree19035c5e15dbe4b227a76e3deaeffbd68afeb68f /dovetail/tests/unit/test_report.py
parent0856c3ab2083ed8b8f16572c0f0b249aab203e69 (diff)
Calculate checksum for input VNF
This patch adds checksum information inside ONAP related test case run results. The checksum is produced by the VNF input which can either be a CSAR file or an archive of Heat templates. Change-Id: I0ed58bdc9cc4031da08fd2ac220ef294520ef447 Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
Diffstat (limited to 'dovetail/tests/unit/test_report.py')
-rw-r--r--dovetail/tests/unit/test_report.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py
index be56e15c..e44c6ac8 100644
--- a/dovetail/tests/unit/test_report.py
+++ b/dovetail/tests/unit/test_report.py
@@ -225,7 +225,9 @@ class ReportTesting(unittest.TestCase):
@patch('dovetail.report.datetime.datetime')
@patch('dovetail.report.dt_cfg')
- def test_generate_json_no_list(self, mock_config, mock_datetime):
+ @patch.object(dt_report.Report, 'get_checksum')
+ def test_generate_json_no_list(self, mock_checksum, mock_config,
+ mock_datetime):
logger_obj = Mock()
report = dt_report.Report()
report.logger = logger_obj
@@ -238,12 +240,14 @@ class ReportTesting(unittest.TestCase):
utc_obj = Mock()
utc_obj.strftime.return_value = '2018-01-13 13:13:13 UTC'
mock_datetime.utcnow.return_value = utc_obj
+ mock_checksum.return_value = 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
result = report.generate_json([], duration)
expected = {
'version': '2018.09',
'build_tag': 'build_tag',
'vnf_type': 'tosca',
+ 'vnf_checksum': 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
'test_date': '2018-01-13 13:13:13 UTC',
'duration': duration,
'testcases_list': []
@@ -1466,3 +1470,44 @@ class ReportTesting(unittest.TestCase):
dt_report.OnapVvpChecker.check(testcase_obj, result)
testcase_obj.passed.assert_called_once_with('PASS')
+
+ @patch('dovetail.report.dt_cfg')
+ @patch('dovetail.report.os.path')
+ @patch('__builtin__.open')
+ @patch('dovetail.report.os.getenv')
+ def test_get_checksum_tosca(self, mock_env, mock_open, mock_path,
+ mock_config):
+ mock_config.dovetail_config = {
+ 'config_dir': 'config_dir'
+ }
+ mock_env.return_value = 'csar_file'
+ file_obj = Mock()
+ file_obj.read.return_value = 'info'
+ file_obj.__exit__ = Mock()
+ file_obj.__enter__ = Mock()
+ mock_open.return_value = file_obj
+ mock_path.isdir.return_value = False
+ mock_path.isfile.return_value = True
+
+ dt_report.Report.get_checksum('tosca')
+
+ @patch('dovetail.report.dt_cfg')
+ @patch('dovetail.report.os.path')
+ @patch('dovetail.report.os.walk')
+ @patch('__builtin__.open')
+ @patch('dovetail.report.os.getenv')
+ def test_get_checksum_heat(self, mock_env, mock_open, mock_walk, mock_path,
+ mock_config):
+ mock_config.dovetail_config = {
+ 'config_dir': 'config_dir'
+ }
+ mock_env.return_value = 'heat_templates_archive'
+ file_obj = Mock()
+ file_obj.read.return_value = 'info'
+ file_obj.__exit__ = Mock()
+ file_obj.__enter__ = Mock()
+ mock_open.return_value = file_obj
+ mock_path.isdir.return_value = True
+ mock_walk.return_value = [('root', ['dir'], ['file'])]
+
+ dt_report.Report.get_checksum('heat')