0001-python3-encoding-correction-on-hobo_deploy.py-40726.patch
bijoe/hobo_agent/management/commands/hobo_deploy.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import os |
18 | 18 |
import urlparse |
19 | 19 |
import ConfigParser |
20 | 20 | |
21 |
from django.utils.encoding import force_text |
|
22 | ||
21 | 23 |
from tenant_schemas.utils import tenant_context |
22 | 24 |
from hobo.agent.common.management.commands import hobo_deploy |
23 | 25 |
from hobo.multitenant.settings_loaders import KnownServices |
24 | 26 | |
25 | 27 |
from django.conf import settings |
26 | 28 | |
27 | 29 | |
28 | 30 |
def pg_dsn_quote(value): |
... | ... | |
83 | 85 |
key = KnownServices.shared_secret(our_key, their_key) |
84 | 86 | |
85 | 87 |
if config.has_section(base_url): |
86 | 88 |
config.remove_section(base_url) |
87 | 89 |
config.add_section(base_url) |
88 | 90 |
config.set(base_url, 'orig', orig) |
89 | 91 |
config.set(base_url, 'key', key) |
90 | 92 |
config.set(base_url, 'schema', schema) |
91 |
config.set(base_url, 'cubes_label', service.get('title').encode('utf-8'))
|
|
93 |
config.set(base_url, 'cubes_label', force_text(service.get('title')))
|
|
92 | 94 |
if 'slug' in service: |
93 | 95 |
config.set(base_url, 'cubes_slug', service['slug']) |
94 | 96 |
with open(ini_file, 'w') as f: |
95 | 97 |
config.write(f) |
tests/test_hobo_deploy.py | ||
---|---|---|
71 | 71 |
config.readfp(fd) |
72 | 72 |
pg_dsn = config.get('wcs-olap', 'pg_dsn') |
73 | 73 |
parsed_pg_dsn = parse_dsn(pg_dsn) |
74 | 74 |
assert parsed_pg_dsn['dbname'] == 'coucou' |
75 | 75 |
assert parsed_pg_dsn['host'] == 'hostname.zob.org' |
76 | 76 |
assert parsed_pg_dsn['user'] == 'hep' |
77 | 77 |
assert parsed_pg_dsn['password'] == 'a \'%fc' |
78 | 78 |
assert parsed_pg_dsn['port'] == '1234' |
79 | ||
80 |
bijoe_base_url = 'https://bijoe.publik.love' |
|
81 |
wcs_base_url = 'https://wcs.publik.love' |
|
82 |
hobo_environment = { |
|
83 |
'services': [ |
|
84 |
{ |
|
85 |
'this': True, |
|
86 |
'secret_key': 'xx', |
|
87 |
'service-id': 'bijoe', |
|
88 |
'base_url': bijoe_base_url, |
|
89 |
}, |
|
90 |
{ |
|
91 |
'this': False, |
|
92 |
'secret_key': 'yy', |
|
93 |
'service-id': 'wcs', |
|
94 |
'base_url': wcs_base_url, |
|
95 |
'title': 'my title', |
|
96 |
'slug': 'my_slug', |
|
97 |
}, |
|
98 |
{ |
|
99 |
'this': False, |
|
100 |
'secret_key': 'zz', |
|
101 |
'service-id': 'wcs', |
|
102 |
'base_url': 'https://wcs-2.publik.love', |
|
103 |
'secondary': True, |
|
104 |
}, |
|
105 |
], |
|
106 |
} |
|
107 |
command.deploy_specifics(hobo_environment, tenant) |
|
108 |
with wcs_olap_ini_path.open() as fd: |
|
109 |
config = ConfigParser.SafeConfigParser() |
|
110 |
config.readfp(fd) |
|
111 |
assert config.get(wcs_base_url, 'orig') == 'bijoe.publik.love' |
|
112 |
assert config.get(wcs_base_url, 'schema') == 'wcs_publik_love' |
|
113 |
assert config.get(wcs_base_url, 'cubes_label') == 'my title' |
|
114 |
assert config.get(wcs_base_url, 'cubes_slug') == 'my_slug' |
|
115 | ||
116 |
hobo_environment['services'][0]['base_url'] = 'https://new-bijoe.publik.love' |
|
117 |
command.deploy_specifics(hobo_environment, tenant) |
|
118 |
with wcs_olap_ini_path.open() as fd: |
|
119 |
config = ConfigParser.SafeConfigParser() |
|
120 |
config.readfp(fd) |
|
121 |
assert config.get(wcs_base_url, 'orig') == 'new-bijoe.publik.love' |
|
79 |
- |