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