Add vnfd validity check
[vfc/gvnfm/vnflcm.git] / lcm / lcm / pub / verifyvnfd / tests.py
1 # Copyright 2018 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain 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,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import unittest
16 from lcm.pub.verifyvnfd import verifyvnfd
17 from . import const
18 from lcm.pub.exceptions import NFLCMException
19
20
21 class VerifyVnfdTest(unittest.TestCase):
22     def setUp(self):
23         pass
24
25     def tearDown(self):
26         pass
27
28     def test_vnfd_verfify_success1(self):
29         ret = verifyvnfd.verify(const.vnfd_model1)
30         self.assertEqual(ret, True)
31
32     def test_vnfd_verfify_success2(self):
33         ret = verifyvnfd.verify(const.vnfd_model2)
34         self.assertEqual(ret, True)
35
36     def test_vnfd_verfify_success3(self):
37         ret = verifyvnfd.verify(const.vnfd_model3)
38         self.assertEqual(ret, True)
39
40     def test_vnfd_verfify_fail_for_missing_required(self):
41         try:
42             verifyvnfd.verify(const.vnfd_model_miss_required)
43         except NFLCMException as e:
44             self.assertNotEqual(e.args[0], "")