-
Notifications
You must be signed in to change notification settings - Fork 1
/
conftest.py
54 lines (44 loc) · 2.42 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
import os
import base64
import betamax
from betamax_serializers import pretty_json
betamax.Betamax.register_serializer(pretty_json.PrettyJSONSerializer)
netapp_username = os.environ.get('NETAPP_USERNAME', "user-placeholder")
netapp_password = os.environ.get('NETAPP_PASSWORD', "password-placeholder")
netapp_hostname = os.environ.get('NETAPP_HOST', 'db-51195')
ontap_username = os.environ.get('ONTAP_USERNAME', 'user-placeholder')
ontap_password = os.environ.get('ONTAP_PASSWORD', 'password-placeholder')
ontap_hostname = os.environ.get('ONTAP_HOST', 'dbnasa-cluster-mgmt')
ontap_vserver = os.environ.get('ONTAP_VSERVER', 'vs1rac11')
def pytest_addoption(parser):
parser.addoption("--betamax-record-mode", action="store", default="once",
help="Use betamax recording option (once, new_episodes, never)")
def pytest_cmdline_main(config):
with betamax.Betamax.configure() as bm_config:
record_mode = config.getoption("--betamax-record-mode")
bm_config.default_cassette_options['record_mode'] = record_mode
with betamax.Betamax.configure() as config:
config.cassette_library_dir = 'netapp/tests/cassettes'
config.default_cassette_options['serialize_with'] = 'prettyjson'
config.default_cassette_options['match_requests_on'] = [
'method',
'uri',
]
config.define_cassette_placeholder('<OCUM-AUTH>',
base64.b64encode(
('{0}:{1}'
.format(netapp_username,
netapp_password)).encode('utf-8'))
.decode('utf-8'))
# Replace the base64-encoded username:password string in the
# basicauth headers with a placeholder to avoid exposing cleartext
# passwords in checked-in content.
config.define_cassette_placeholder('<ONTAP-AUTH>',
base64.b64encode(
('{0}:{1}'
.format(ontap_username,
ontap_password)).encode('utf-8'))
.decode('utf-8'))
config.define_cassette_placeholder('<ONTAP-HOST>', ontap_hostname)
config.define_cassette_placeholder('<NETAPP-HOST>', netapp_hostname)
config.define_cassette_placeholder('<ONTAP-VSERVER>', ontap_vserver)