Skip to content
Snippets Groups Projects
Commit 29842141 authored by Georges Racinet's avatar Georges Racinet
Browse files

wsgi: actually using the given configuration file

This actually finishes ec9c7408d7df,
in which I forgot to use the value. That was wrong, yet didn't break
anything in practice, because the hardcoded value is still the only
useful one outside of tests.

Doing the conditional instantiation in a class method allows to test it
independently without resorting to ugly stuff such as module
reload.
parent 2e5babd5
No related branches found
No related tags found
No related merge requests found
Pipeline #
import os
import pytest import pytest
from mercurial import ( from mercurial import (
error, error,
...@@ -43,6 +44,24 @@ ...@@ -43,6 +44,24 @@
assert hgs.repos_root == str(tmpdir) assert hgs.repos_root == str(tmpdir)
def test_config_from_environ(tmpdir):
assert 'HEPTAPOD_HGRC' not in os.environ # checking our premises
hgrc = tmpdir.join('hgrc')
repos = tmpdir.join('repositories')
hgrc.write('\n'.join(('[heptapod]\n',
'repositories-root=' + str(repos),
)))
try:
os.environ['HEPTAPOD_HGRC'] = str(hgrc)
hgs = HgServe.default_app()
assert hgs.repos_root == str(repos)
finally:
del os.environ['HEPTAPOD_HGRC']
# really make sure we won't pollute other tests
assert 'HEPTAPOD_HGRC' not in os.environ
def test_apply_heptapod_headers(tmpdir): def test_apply_heptapod_headers(tmpdir):
hgs = make_hgserve(tmpdir) hgs = make_hgserve(tmpdir)
......
...@@ -182,4 +182,9 @@ ...@@ -182,4 +182,9 @@
res.setbodygen((e.message or b'') + b"\n") res.setbodygen((e.message or b'') + b"\n")
return res.sendresponse() return res.sendresponse()
@classmethod
def default_app(cls):
HEPTAPOD_HGRC = os.environ.get('HEPTAPOD_HGRC')
if HEPTAPOD_HGRC:
return HgServe(conf_path=HEPTAPOD_HGRC)
...@@ -185,4 +190,3 @@ ...@@ -185,4 +190,3 @@
HEPTAPOD_HGRC = os.environ.get('HEPTAPOD_HGRC')
if HEPTAPOD_HGRC: hgserve = HgServe.default_app()
hgserve = HgServe(conf_path="/etc/gitlab/heptapod.hgrc")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment