Gopinath Taget | 22383d9 | 2018-08-22 12:28:52 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # Tests for VEpcServiceInstance model policies |
| 17 | |
| 18 | import base64 |
| 19 | import json |
| 20 | import os |
| 21 | import sys |
| 22 | import unittest |
| 23 | from mock import patch, PropertyMock, ANY, MagicMock |
| 24 | from unit_test_common import setup_sync_unit_test |
| 25 | |
| 26 | |
| 27 | class TestVEpcServiceInstancePolicy(unittest.TestCase): |
| 28 | |
| 29 | def setUp(self): |
| 30 | self.unittest_setup = setup_sync_unit_test(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), |
| 31 | globals(), |
| 32 | [("vepcservice", "vepcservice.xproto"), |
| 33 | ("kubernetes-service", "kubernetes.xproto")] ) |
| 34 | |
| 35 | self.MockObjectList = self.unittest_setup["MockObjectList"] |
| 36 | |
| 37 | sys.path.append(os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), "../model_policies")) |
| 38 | |
| 39 | from model_policy_vepcserviceinstance import VEpcServiceInstancePolicy |
| 40 | self.policy_class = VEpcServiceInstancePolicy |
| 41 | |
| 42 | self.service = VEpcService() |
| 43 | self.k8s_service = KubernetesService(id=1111) |
| 44 | self.k8s_service.get_service_instance_class=MagicMock(return_value=KubernetesServiceInstance) |
| 45 | self.trust_domain = TrustDomain(owner=self.k8s_service, name="test-trust") |
| 46 | self.image = Image(name="test-image", tag="1.2", kind="container") |
| 47 | self.slice = Slice(trust_domain=self.trust_domain, service=self.service, default_image = self.image) |
| 48 | self.service.slices = self.MockObjectList([self.slice]) |
| 49 | |
| 50 | def tearDown(self): |
| 51 | sys.path = self.unittest_setup["sys_path_save"] |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | unittest.main() |