Fix bug 1731: backwards compatibility of relations
[osm/IM.git] / tests / test_python.py
1 # Copyright 2020 ETSI
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
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 import osm_im.vnfd as vnfd_catalog
17 from pyangbind.lib.serialise import pybindJSONDecoder
18 import unittest
19 import yaml
20
21 VNFD_YAML = """
22 vnfd-catalog:
23 vnfd:
24 - id: cirros_vnfd
25 name: cirros_vnf
26 short-name: cirros_vnf
27 description: Simple VNF example with a cirros
28 vendor: OSM
29 version: '1.0'
30
31 # Place the logo as png in icons directory and provide the name here
32 logo: cirros-64.png
33
34 # Management interface
35 mgmt-interface:
36 cp: eth0
37
38 # Atleast one VDU need to be specified
39 vdu:
40 - id: cirros_vnfd-VM
41 name: cirros_vnfd-VM
42 description: cirros_vnfd-VM
43 count: 1
44
45 # Flavour of the VM to be instantiated for the VDU
46 # flavor below can fit into m1.micro
47 vm-flavor:
48 vcpu-count: 1
49 memory-mb: 256
50 storage-gb: 2
51
52 # Image/checksum or image including the full path
53 image: 'cirros034'
54 #checksum:
55
56 interface:
57 # Specify the external interfaces
58 # There can be multiple interfaces defined
59 - name: eth0
60 type: EXTERNAL
61 virtual-interface:
62 type: PARAVIRT
63 bandwidth: '0'
64 vpci: 0000:00:0a.0
65 external-connection-point-ref: eth0
66
67 connection-point:
68 - name: eth0
69 type: VPORT
70 """
71
72 class PythonTest(unittest.TestCase):
73
74
75 def test_python_compatibility(self):
76 """A simple test to verify Python compatibility.
77
78 This test exercises basic IM interoperability with supported versions
79 of Python in order to verify the IM libraries compatibility.
80
81 As of 30 Nov 2017, the IM library fails with Python3. This invokes that
82 failing code so that it can be repeatably tested:
83
84 ValueError: '_pybind_generated_by' in __slots__ conflicts with class variable
85 """
86
87 try:
88 data = yaml.safe_load(VNFD_YAML)
89
90 myvnfd = vnfd_catalog.vnfd()
91 pybindJSONDecoder.load_ietf_json(data, None, None, obj=myvnfd)
92 except ValueError:
93 assert False