This repository has been archived by the owner on Sep 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
plugin.py
85 lines (67 loc) · 2.55 KB
/
plugin.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
# Copyright (C) 2013 by Clearcode <http://clearcode.cc>
# and associates (see AUTHORS).
# This file is part of pytest-dbfixtures.
# pytest-dbfixtures is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# pytest-dbfixtures is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with pytest-dbfixtures. If not, see <http://www.gnu.org/licenses/>.
from path import path
from pytest_dbfixtures import factories
ROOT_DIR = path(__file__).parent.parent.abspath()
CONF_DIR = ROOT_DIR / 'pytest_dbfixtures' / 'conf'
def pytest_addoption(parser):
parser.addoption(
'--dbfixtures-config',
action='store',
default=str(CONF_DIR / 'dbfixtures.conf'),
metavar='path',
dest='db_conf',
)
parser.addoption(
'--redis-config',
action='store',
default=str(CONF_DIR / 'redis.conf'),
metavar='path',
dest='redis_conf',
)
parser.addoption(
'--rabbit-config',
action='store',
default=str(CONF_DIR / 'rabbit.conf'),
metavar='path',
dest='rabbit_conf',
)
parser.addoption(
'--dbfixtures-logsdir',
action='store',
default='/tmp',
metavar='path',
dest='logsdir',
)
def pytest_load_initial_conftests(early_config, parser, args):
"""Validate paths passed to py.test."""
db_conf = early_config.getvalue('db_conf')
if db_conf and not path(db_conf).isfile():
raise ValueError(
'argument passed to --dbfixtures-config is not a valid file path'
)
redis_conf = early_config.getvalue('redis_conf')
if redis_conf and not path(redis_conf).isfile():
raise ValueError(
'argument passed to --redis-config is not a valid file path'
)
rabbit_conf = early_config.getvalue('rabbit_conf')
if rabbit_conf and not path(rabbit_conf).isfile():
raise ValueError(
'argument passed to --rabbit-config is not a valid file path'
)
redis_proc = factories.redis_proc()
redisdb = factories.redisdb('redis_proc')
rabbitmq_proc = factories.rabbitmq_proc()
rabbitmq = factories.rabbitmq('rabbitmq_proc')