Convert file endlines to Unix (LF)
[pti/o2.git] / tests / integration / test_clientdriver_fake_stx_sa.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 datetime import date, datetime
16 import sys
17 import pytest
18 from o2ims.adapter import ocloud_repository as repository
19 from o2ims.domain import ocloud
20 from o2common.config import config
21 import logging
22 import uuid
23 import json
24 from o2ims.adapter.clients.ocloud_sa_client import StxSaOcloudClient
25 from o2ims.domain import stx_object as ocloudModel
26 from o2ims.domain.resource_type import ResourceTypeEnum
27
28 # pytestmark = pytest.mark.usefixtures("mappers")
29
30
31 class FakeStxSaClientImp(object):
32     def __init__(self):
33         super().__init__()
34
35     def getInstanceInfo(self) -> ocloudModel.StxGenericModel:
36         model = ocloudModel.StxGenericModel(ResourceTypeEnum.OCLOUD)
37         model.id = uuid.uuid4()
38         model.name = "stx1"
39         model.updatetime = datetime.now
40         model.createtime = datetime.now
41         model.content = json.dumps({})
42         return model
43
44
45 @pytest.fixture
46 def fake_driver_imp():
47     fakedriver = FakeStxSaClientImp()
48     yield fakedriver
49
50
51 def test_get_instanceinfo(fake_driver_imp):
52     logger = logging.getLogger(__name__)
53     stxclientimp = StxSaOcloudClient(fake_driver_imp)
54     assert stxclientimp is not None
55     systeminfo = stxclientimp.get(None)
56     assert systeminfo is not None
57     assert systeminfo.id is not None
58     assert systeminfo.name == "stx1"
59     assert systeminfo.content == json.dumps({})