-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A utility to generate statistics (gauges) about the row counts.
- Loading branch information
Patrick Valsecchi
committed
Jun 2, 2017
1 parent
3181905
commit 2351df6
Showing
16 changed files
with
275 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,5 @@ db_slave: | |
run_test: | ||
image: camptocamp/c2cwsgiutils_test_app:${DOCKER_TAG} | ||
command: 'true' | ||
links: | ||
- db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
import subprocess | ||
|
||
|
||
def test_no_extra(app_connection, composition): | ||
composition.run('run_test', './c2cwsgiutils_stats_db.py', | ||
'--db', 'postgresql://www-data:www-data@db:5432/test', '--schema', 'public') | ||
|
||
|
||
def test_with_extra(app_connection, composition): | ||
composition.run('run_test', './c2cwsgiutils_stats_db.py', | ||
'--db', 'postgresql://www-data:www-data@db:5432/test', '--schema', 'public', | ||
'--extra', "select 'toto', 42") | ||
|
||
|
||
def test_error(app_connection, composition): | ||
with pytest.raises(subprocess.CalledProcessError): | ||
composition.run('run_test', './c2cwsgiutils_stats_db.py', | ||
'--db', 'postgresql://www-data:www-data@db:5432/test', '--schema', 'public', | ||
'--extra', "select 'toto, 42") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pyramid.httpexceptions import HTTPForbidden | ||
|
||
from c2cwsgiutils._utils import env_or_settings | ||
|
||
|
||
def auth_view(request, env_name, config_name): | ||
if request.params.get('secret') != env_or_settings(request.registry.settings, env_name, config_name, | ||
False): | ||
raise HTTPForbidden('Missing or invalid secret parameter') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
""" | ||
Private utilities. | ||
""" | ||
|
||
import os | ||
from pyramid.httpexceptions import HTTPForbidden | ||
|
||
|
||
def get_base_path(config): | ||
return env_or_config(config, 'C2C_BASE_PATH', 'c2c.base_path', '') | ||
|
||
|
||
def env_or_config(config, env_name, config_name, default): | ||
if env_name in os.environ: | ||
return os.environ[env_name] | ||
return config.get_settings().get(config_name, default) | ||
return env_or_settings(config.get_settings(), env_name, config_name, default) | ||
|
||
|
||
def auth_view(request, env_name, config_name): | ||
if request.params.get('secret') != env_or_config(request.registry.settings, env_name, config_name, False): | ||
raise HTTPForbidden('Missing or invalid secret parameter') | ||
def env_or_settings(settings, env_name, settings_name, default): | ||
if env_name in os.environ: | ||
return os.environ[env_name] | ||
return settings.get(settings_name, default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.