forked from mozilla-services/kinto-integration-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
69 lines (50 loc) · 1.62 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
import configparser
import os
import pytest
import ssl
# Hack because of how SSL certificates are verified by default in Python
if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context
def pytest_addoption(parser):
parser.addoption(
"--env",
dest="env",
default="stage",
help="Environment tests are running in: stage or prod"
)
parser.addoption(
"--api-version",
dest="apiversion",
help="Optional param: version of API under test"
)
parser.addoption(
"--qa-collection-user",
dest="qauser",
help="Optional param: user who can access QA collection in staging"
)
parser.addoption(
"--qa-collection-passwd",
dest="qa_passwd",
help="Optional param: password for user who can access QA collection in staging"
)
@pytest.fixture(scope="module")
def conf():
config = configparser.ConfigParser()
config.read('manifest.ini')
return config
@pytest.fixture(scope="module")
def env(request):
return request.config.getoption("--env")
@pytest.fixture(scope="module")
def apiversion(request):
return request.config.getoption("--api-version")
@pytest.fixture(scope="session")
def qauser(pytestconfig):
if os.getenv('KINTO_QA_LOGIN'):
return os.getenv('KINTO_QA_LOGIN')
return pytestconfig.getoption('--qa-collection-user')
@pytest.fixture(scope="session")
def qapasswd(pytestconfig):
if os.getenv('KINTO_QA_PASSWD'):
return os.getenv('KINTO_QA_PASSWD')
return pytestconfig.getoption("--qa-collection-passwd")