3fa617b902757aaf33ce4a5a9a9309caaac6f843
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
19 from unittest
.mock
import patch
, Mock
21 from osm_ng_ro
.ns
import Ns
24 __author__
= "Eduardo Sousa"
25 __date__
= "$19-NOV-2021 00:00:00$"
28 class TestNs(unittest
.TestCase
):
32 def test__create_task(self
):
34 "target_id": "vim_openstack_1",
35 "action_id": "123456",
37 "task_id": "123456:1",
38 "status": "SCHEDULED",
41 "target_record": "test_target_record",
42 "target_record_id": "test_target_record_id",
43 # values coming from extra_dict
44 "params": "test_params",
45 "find_params": "test_find_params",
46 "depends_on": "test_depends_on",
49 "action_id": "123456",
54 task
= Ns
._create
_task
(
55 deployment_info
=deployment_info
,
56 target_id
="vim_openstack_1",
59 target_record
="test_target_record",
60 target_record_id
="test_target_record_id",
62 "params": "test_params",
63 "find_params": "test_find_params",
64 "depends_on": "test_depends_on",
68 self
.assertEqual(deployment_info
.get("task_index"), 2)
69 self
.assertDictEqual(task
, expected_result
)
71 @patch("osm_ng_ro.ns.time")
72 def test__create_ro_task(self
, mock_time
: Mock
):
73 now
= 1637324838.994551
74 mock_time
.return_value
= now
76 "target_id": "vim_openstack_1",
77 "action_id": "123456",
79 "task_id": "123456:1",
80 "status": "SCHEDULED",
83 "target_record": "test_target_record",
84 "target_record_id": "test_target_record_id",
85 # values coming from extra_dict
86 "params": "test_params",
87 "find_params": "test_find_params",
88 "depends_on": "test_depends_on",
94 "target_id": "vim_openstack_1",
97 "created_items": None,
110 ro_task
= Ns
._create
_ro
_task
(
111 target_id
="vim_openstack_1",
115 self
.assertDictEqual(ro_task
, expected_result
)