Skip to content

Commit

Permalink
Merge branch 'adding_route_for_wegobjecten' of https://github.com/Onr…
Browse files Browse the repository at this point in the history
…oerendErfgoed/crabpy_pyramid into adding_route_for_wegobjecten
  • Loading branch information
TalissaJoly committed Apr 8, 2014
2 parents ec18c2c + a6270c0 commit e0d4347
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 14 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -6,9 +6,8 @@ python:
install:
- easy_install -U setuptools
- python setup.py -q install
- pip install nose coverage
- pip install coveralls
- pip install nose coverage nose-testconfig coveralls webtest
script:
nosetests --config nose_cover.cfg
nosetests --nologcapture --config nose_cover.cfg --tc-file nose_travis.ini
after_success:
coveralls
19 changes: 15 additions & 4 deletions crabpy_pyramid/__init__.py
Expand Up @@ -36,7 +36,7 @@ def _parse_settings(settings):
args[short_key_name] = settings.get(
key_name, defaults.get(short_key_name)
)
# not set user or password
# not set user or password
for short_key_name in ('user', 'password'):
if (
(not short_key_name in args) or
Expand All @@ -47,6 +47,10 @@ def _parse_settings(settings):
capakey needs this parameter to function properly.' % short_key_name,
UserWarning
)
# set proxy
args['proxy'] = get_proxy(settings)


return args


Expand All @@ -59,6 +63,13 @@ def _set_caches(settings, gateway, c):
gateway.caches[name] = make_region(key_mangler=str)
gateway.caches[name].configure_from_config(settings, '%s.%s.' % (c, name))

def get_proxy(settings):
args = {}
for short_key_name in ('http', 'https'):
key_name = "proxy.%s" % (short_key_name)
if key_name in settings:
args[short_key_name] = settings.get(key_name)
return args

def _build_capakey(registry):
capakey = registry.queryUtility(ICapakey)
Expand All @@ -79,7 +90,9 @@ def _build_crab(registry):
if crab is not None:
return crab
settings = registry.settings
factory = crab_factory()
proxy = {}
proxy['proxy'] = get_proxy(settings)
factory = crab_factory(**proxy)
gateway = CrabGateway(factory)
_set_caches(settings, gateway, 'crab')

Expand Down Expand Up @@ -130,8 +143,6 @@ def main(global_config, **settings):
This function returns a Pyramid WSGI application.
'''
config = Configurator(settings=settings)



includeme(config)
config.scan()
Expand Down
14 changes: 13 additions & 1 deletion crabpy_pyramid/tests/test_utils.py
Expand Up @@ -14,6 +14,14 @@

from crabpy_pyramid import main

def run_capakey_integration_tests():
from testconfig import config
from crabpy.tests import as_bool
try:
return as_bool(config['capakey']['run_integration_tests'])
except KeyError: # pragma NO COVER
return False

settings = {
'capakey.user': 'USEr',
'capakey.password': 'PSWD',
Expand Down Expand Up @@ -50,7 +58,11 @@ def setUp(self):

def tearDown(self):
testing.tearDown()


@unittest.skipUnless(
run_capakey_integration_tests(),
'No CAPAKEY Integration tests required'
)
class CapakeyFunctionalTests(FunctionalTests):
def test_list_gemeenten(self):
res = self.testapp.get('/capakey/gemeenten')
Expand Down
2 changes: 2 additions & 0 deletions development.ini
Expand Up @@ -34,6 +34,8 @@ crab.long.arguments.filename: dogpile_data/crab_long.dbm
crab.short.backend: dogpile.cache.dbm
crab.short.expiration_time: 3600
crab.short.arguments.filename: dogpile_data/crab_short.dbm
proxy.http = http://proxy.example.com:3128
proxy.https = https://httpsproxy.example.com:3128
# By default, the toolbar only appears for clients from IP addresses
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
Expand Down
7 changes: 7 additions & 0 deletions nose_development.ini
@@ -0,0 +1,7 @@
[crab]
run_integration_tests = True

[capakey]
run_integration_tests = False
user = USER
password = PASSWORD
7 changes: 7 additions & 0 deletions nose_travis.ini
@@ -0,0 +1,7 @@
[crab]
run_integration_tests = 1

[capakey]
run_integration_tests = 0
user = user
password = password
8 changes: 4 additions & 4 deletions setup.py
Expand Up @@ -10,13 +10,13 @@
'pyramid',
'pyramid_debugtoolbar',
'waitress',
'crabpy>=0.3.0',
'webtest'
]
'crabpy>=0.3.2'
]

tests_requires = [
'nose',
'coverage'
'coverage',
'webtest'
]

testing_extras = tests_requires + []
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Expand Up @@ -5,18 +5,20 @@ envlist = py27, cover
[testenv]
commands =
python setup.py develop
python setup.py nosetests -q
python setup.py nosetests --verbose --tc-file nose_development.ini
deps =
nose
nose-testconfig
webtest

[testenv:cover]
basepython =
python2.7
commands =
python setup.py develop
python setup.py nosetests --config nose_cover.cfg
python setup.py nosetests --config nose_cover.cfg --tc-file nose_development.ini
deps =
nose
nose-testconfig
coverage
webtest

0 comments on commit e0d4347

Please sign in to comment.