blob: b83a86070add9384656462ab7c551debe377bc4a [file] [log] [blame]
Lianhao Lu0af46242018-08-29 18:17:46 +08001# Copyright (c) 2018 Intel Corp. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14#
15
16import pytest
17
18from vnfsdk_pkgtools import vnfreq
19
Lianhao Lu40bcf5a2018-08-30 10:24:40 +080020
21def check_result(reqid, reader, tosca, expected_fail_msg):
22 tester = vnfreq.get_vnfreq_tester(reqid)
23 tester.check(reader, tosca)
24 if expected_fail_msg:
25 assert isinstance(tester.err, vnfreq.VnfRequirementError)
26 assert expected_fail_msg in str(tester.err)
27 else:
28 assert tester.err == 0
29
30
31def test_R66070(mocker):
Lianhao Lu0af46242018-08-29 18:17:46 +080032 reader = mocker.Mock()
33 reader.manifest = None
Lianhao Lu40bcf5a2018-08-30 10:24:40 +080034 check_result('R-66070', reader, None, 'No manifest file found')
Lianhao Lu0af46242018-08-29 18:17:46 +080035
Lianhao Lu40bcf5a2018-08-30 10:24:40 +080036
37def test_R77707(mocker, tmpdir):
38 # check only manifest file - success
39 p1 = tmpdir.join("manifest.mf")
40 p1.write("manifest")
41 reader = mocker.Mock()
42 reader.destination = str(tmpdir)
43 reader.entry_manifest_file = "manifest.mf"
44 reader.manifest.digests = {}
45 check_result('R-77707', reader, None, None)
46
47 # check additional file - fail
48 p2 = tmpdir.mkdir('sub').join("non-existing")
49 p2.write("non existing")
50 check_result('R-77707', reader, None,
51 'Package component sub/non-existing not found in manifest file')
Lianhao Lu0af46242018-08-29 18:17:46 +080052