Update watcher worker
[pti/o2.git] / tests / unit / test_ocloud.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
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 from o2ims.domain import ocloud
16 from o2ims import config
17 import uuid
18
19
20 def setup_ocloud():
21     ocloudid1 = str(uuid.uuid4())
22     ocloud1 = ocloud.Ocloud(ocloudid1, "ocloud1", config.get_api_url(), "ocloud for unit test", 1)
23     return ocloud1
24
25 def test_new_ocloud():
26     ocloudid1 = str(uuid.uuid4())
27     ocloud1 = ocloud.Ocloud(ocloudid1, "ocloud1", config.get_api_url(), "ocloud for unit test", 1)
28     assert ocloudid1 is not None and ocloud1.oCloudId == ocloudid1
29
30 def test_add_ocloud_with_dms():
31     ocloud1 = setup_ocloud()
32     dmsid = str(uuid.uuid4())
33     dms = ocloud.DeploymentManager(
34         dmsid, "k8s1", ocloud1.oCloudId, config.get_api_url()+"/k8s1")
35     ocloud1.addDeploymentManager(dms)
36     ocloud1.addDeploymentManager(dms)
37     assert len(ocloud1.deploymentManagers) == 1
38     # repo.update(ocloud1.oCloudId, {"deploymentManagers": ocloud1.deploymentManagers})