forked from F5Networks/f5-icontrol-rest-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
100 lines (71 loc) · 2.8 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 2015-2016 F5 Networks Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from icontrol.session import iControlRESTSession
import pytest
def pytest_addoption(parser):
parser.addoption("--bigip", action="store", default='localhost',
help="BIG-IP hostname or IP address")
parser.addoption("--username", action="store", help="BIG-IP REST username",
default="admin")
parser.addoption("--port", action="store", help="BIG-IP port",
default='443')
parser.addoption("--password", action="store", help="BIG-IP REST password",
default="admin")
# These are optional; if not specified, tests skip.
parser.addoption("--nonadmin-username", action="store",
help="BIG-IP REST username for non-admin user",
default=None)
parser.addoption("--nonadmin-password", action="store",
help="BIG-IP REST password for non-admin user",
default=None)
def pytest_generate_tests(metafunc):
assert metafunc.config.option.bigip
@pytest.fixture
def opt_bigip(request):
return request.config.getoption("--bigip")
@pytest.fixture
def opt_username(request):
return request.config.getoption("--username")
@pytest.fixture
def opt_password(request):
return request.config.getoption("--password")
@pytest.fixture
def opt_port(request):
return request.config.getoption("--port")
@pytest.fixture
def opt_nonadmin_username(request):
return request.config.getoption("--nonadmin-username")
@pytest.fixture
def opt_nonadmin_password(request):
return request.config.getoption("--nonadmin-password")
@pytest.fixture
def ICR(opt_bigip, opt_username, opt_password):
icr = iControlRESTSession(opt_username, opt_password)
return icr
@pytest.fixture
def GET_URL(opt_bigip, opt_port):
url = 'https://' + opt_bigip + ':' + opt_port + '/mgmt/tm/ltm/nat/'
return url
@pytest.fixture
def POST_URL(opt_bigip, opt_port):
url = 'https://' + opt_bigip + ':' + opt_port + '/mgmt/tm/ltm/nat/'
return url
@pytest.fixture
def FAKE_URL(opt_bigip, opt_port):
fake_url = 'https://' + opt_bigip + ':' + opt_port + '/mgmt/tm/bogus/'
return fake_url
@pytest.fixture
def BASE_URL(opt_bigip):
return 'https://' + opt_bigip + '/mgmt/tm/'