|
1 |
# -*- coding: utf-8 -*-
|
1 |
2 |
# bijoe - BI dashboard
|
2 |
3 |
# Copyright (C) 2015 Entr'ouvert
|
3 |
4 |
#
|
4 |
5 |
# This program is free software: you can redistribute it and/or modify it
|
5 |
6 |
# under the terms of the GNU Affero General Public License as published
|
6 |
7 |
# by the Free Software Foundation, either version 3 of the License, or
|
7 |
8 |
# (at your option) any later version.
|
8 |
9 |
#
|
... | ... | |
10 |
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
13 |
# GNU Affero General Public License for more details.
|
13 |
14 |
#
|
14 |
15 |
# You should have received a copy of the GNU Affero General Public License
|
15 |
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 |
17 |
|
17 |
18 |
from contextlib import contextmanager
|
18 |
|
import ConfigParser
|
19 |
|
|
20 |
19 |
from psycopg2.extensions import parse_dsn
|
21 |
20 |
|
|
21 |
from django.utils.six.moves import configparser as ConfigParser
|
|
22 |
|
22 |
23 |
from bijoe.hobo_agent.management.commands import hobo_deploy
|
23 |
24 |
|
24 |
25 |
|
25 |
26 |
@contextmanager
|
26 |
27 |
def donothing(tenant):
|
27 |
28 |
yield
|
28 |
29 |
|
29 |
30 |
|
... | ... | |
71 |
72 |
config.readfp(fd)
|
72 |
73 |
pg_dsn = config.get('wcs-olap', 'pg_dsn')
|
73 |
74 |
parsed_pg_dsn = parse_dsn(pg_dsn)
|
74 |
75 |
assert parsed_pg_dsn['dbname'] == 'coucou'
|
75 |
76 |
assert parsed_pg_dsn['host'] == 'hostname.zob.org'
|
76 |
77 |
assert parsed_pg_dsn['user'] == 'hep'
|
77 |
78 |
assert parsed_pg_dsn['password'] == 'a \'%fc'
|
78 |
79 |
assert parsed_pg_dsn['port'] == '1234'
|
|
80 |
|
|
81 |
bijoe_base_url = 'https://bijoe.example.net'
|
|
82 |
wcs_base_url = 'https://wcs.example.net'
|
|
83 |
hobo_environment = {
|
|
84 |
'services': [
|
|
85 |
{
|
|
86 |
'this': True,
|
|
87 |
'secret_key': 'xx',
|
|
88 |
'service-id': 'bijoe',
|
|
89 |
'base_url': bijoe_base_url,
|
|
90 |
},
|
|
91 |
{
|
|
92 |
'this': False,
|
|
93 |
'secret_key': 'yy',
|
|
94 |
'service-id': 'wcs',
|
|
95 |
'base_url': wcs_base_url,
|
|
96 |
'title': 'my läâàlel',
|
|
97 |
'slug': 'my_slug',
|
|
98 |
},
|
|
99 |
{
|
|
100 |
'this': False,
|
|
101 |
'secret_key': 'zz',
|
|
102 |
'service-id': 'wcs',
|
|
103 |
'base_url': 'https://wcs-2.example.net',
|
|
104 |
'secondary': True,
|
|
105 |
},
|
|
106 |
],
|
|
107 |
}
|
|
108 |
command.deploy_specifics(hobo_environment, tenant)
|
|
109 |
with wcs_olap_ini_path.open() as fd:
|
|
110 |
config = ConfigParser.SafeConfigParser()
|
|
111 |
config.readfp(fd)
|
|
112 |
assert config.get(wcs_base_url, 'orig') == 'bijoe.example.net'
|
|
113 |
assert config.get(wcs_base_url, 'schema') == 'wcs_example_net'
|
|
114 |
assert config.get(wcs_base_url, 'cubes_label') == 'my läâàlel'
|
|
115 |
assert config.get(wcs_base_url, 'cubes_slug') == 'my_slug'
|
|
116 |
|
|
117 |
hobo_environment['services'][0]['base_url'] = 'https://new-bijoe.example.net'
|
|
118 |
command.deploy_specifics(hobo_environment, tenant)
|
|
119 |
with wcs_olap_ini_path.open() as fd:
|
|
120 |
config = ConfigParser.SafeConfigParser()
|
|
121 |
config.readfp(fd)
|
|
122 |
assert config.get(wcs_base_url, 'orig') == 'new-bijoe.example.net'
|
79 |
|
-
|