robot tcs, test charts, robot container added
[ta/cloudtaf.git] / cluster / conftest.py
1 # Copyright 2019 Nokia
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 # pylint: disable=redefined-outer-name
16 import pytest
17 import mock
18 from crl.remotesession.remotesession import RemoteSession
19 from hostcli import HostCli
20 from .clusterverifier import (
21     Type1Verifier,
22     Type2Verifier,
23     ClusterMocks)
24 from .userverifier import UserVerifier
25 from .envcreatorverifier import EnvCreatorVerifier
26 from . import cluster
27 from . import usermanager
28 from .envcreator import EnvCreator
29
30
31 @pytest.fixture(params=[Type1Verifier,
32                         Type2Verifier])
33 def clusterverifier(request, clustermocks):
34     return request.param(clustermocks)
35
36
37 @pytest.fixture
38 def clustermocks(mock_remotesession, mock_hostcli, mock_envcreator, mock_usermanager):
39     return ClusterMocks(remotesession=mock_remotesession,
40                         hostcli=mock_hostcli,
41                         envcreator=mock_envcreator,
42                         usermanager=mock_usermanager)
43
44
45 @pytest.fixture
46 def mock_remotesession():
47     with mock.patch.object(cluster,
48                            'RemoteSession',
49                            mock.create_autospec(RemoteSession)) as p:
50         yield p
51
52
53 @pytest.fixture
54 def mock_hostcli():
55     with mock.patch.object(cluster,
56                            'HostCli',
57                            mock.create_autospec(HostCli)) as p:
58         yield p
59
60
61 @pytest.fixture
62 def mock_envcreator():
63     with mock.patch.object(cluster,
64                            'EnvCreator',
65                            mock.create_autospec(EnvCreator)) as p:
66         yield p
67
68
69 @pytest.fixture
70 def mock_usermanager():
71     with mock.patch.object(cluster,
72                            'UserManager',
73                            mock.create_autospec(usermanager.UserManager)) as p:
74         yield p
75
76
77 @pytest.fixture(params=['Role', 'Role-Name'])
78 def userverifier(request):
79     return UserVerifier(role_attr=request.param)
80
81
82 @pytest.fixture
83 def envcreatorverifier():
84     return EnvCreatorVerifier()