Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Rename get_test_app() to make_app() to please nose
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Nov 4, 2015
1 parent 7a369f6 commit 68d2c3e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cliquet/tests/resource/test_events.py
Expand Up @@ -38,7 +38,7 @@ def tearDown(self):
def listener(self, event):
self.events.append(event)

def get_test_app(self, settings=None):
def make_app(self, settings=None):
settings = self.get_app_settings(settings)
self.config = Configurator(settings=settings)
app = testapp(config=self.config)
Expand Down
8 changes: 4 additions & 4 deletions cliquet/tests/resource/test_views_cors.py
Expand Up @@ -20,7 +20,7 @@ def setUp(self):
self.record = response.json['data']

def test_can_be_configured_from_settings(self):
app = self.get_test_app({'cors_origins': '*.daybed.io'})
app = self.make_app({'cors_origins': '*.daybed.io'})
headers = self.headers.copy()
headers['Origin'] = 'demo.daybed.io'
resp = app.get(self.collection_url, headers=headers)
Expand Down Expand Up @@ -190,16 +190,16 @@ def setUp(self):
})

def test_cors_max_age_is_3600_seconds_by_default(self):
app = self.get_test_app()
app = self.make_app()
resp = app.options('/', headers=self.headers)
self.assertEqual(int(resp.headers['Access-Control-Max-Age']), 3600)

def test_cors_max_age_can_be_specified_in_settings(self):
app = self.get_test_app({'cors_max_age_seconds': '42'})
app = self.make_app({'cors_max_age_seconds': '42'})
resp = app.options('/', headers=self.headers)
self.assertEqual(int(resp.headers['Access-Control-Max-Age']), 42)

def test_cors_max_age_is_disabled_if_unset(self):
app = self.get_test_app({'cors_max_age_seconds': ''})
app = self.make_app({'cors_max_age_seconds': ''})
resp = app.options('/', headers=self.headers)
self.assertNotIn('Access-Control-Max-Age', resp.headers)
4 changes: 2 additions & 2 deletions cliquet/tests/support.py
Expand Up @@ -79,7 +79,7 @@ class BaseWebTest(object):

def __init__(self, *args, **kwargs):
super(BaseWebTest, self).__init__(*args, **kwargs)
self.app = self.get_test_app()
self.app = self.make_app()
self.storage = self.app.app.registry.storage
self.cache = self.app.app.registry.cache
self.permission = self.app.app.registry.permission
Expand All @@ -88,7 +88,7 @@ def __init__(self, *args, **kwargs):
'Authorization': 'Basic bWF0OjE='
}

def get_test_app(self, settings=None):
def make_app(self, settings=None):
app = webtest.TestApp(testapp(self.get_app_settings(settings)))
app.RequestClass = get_request_class(self.api_prefix)
return app
Expand Down
8 changes: 4 additions & 4 deletions cliquet/tests/test_authentication.py
Expand Up @@ -12,22 +12,22 @@ class AuthenticationPoliciesTest(BaseWebTest, unittest.TestCase):
sample_basicauth = {'Authorization': 'Basic bWF0OjE='}

def test_basic_auth_is_accepted_by_default(self):
app = self.get_test_app()
app = self.make_app()
app.get(self.sample_url, headers=self.sample_basicauth, status=200)

def test_basic_auth_is_accepted_if_enabled_in_settings(self):
app = self.get_test_app({'multiauth.policies': 'basicauth'})
app = self.make_app({'multiauth.policies': 'basicauth'})
app.get(self.sample_url, headers=self.sample_basicauth, status=200)

def test_basic_auth_is_declined_if_disabled_in_settings(self):
app = self.get_test_app({
app = self.make_app({
'multiauth.policies': 'dummy',
'multiauth.policy.dummy.use': ('pyramid.authentication.'
'RepozeWho1AuthenticationPolicy')})
app.get(self.sample_url, headers=self.sample_basicauth, status=401)

def test_views_are_forbidden_if_unknown_auth_method(self):
app = self.get_test_app({'multiauth.policies': 'basicauth'})
app = self.make_app({'multiauth.policies': 'basicauth'})
self.headers['Authorization'] = 'Carrier'
app.get(self.sample_url, headers=self.headers, status=401)
self.headers['Authorization'] = 'Carrier pigeon'
Expand Down
2 changes: 1 addition & 1 deletion cliquet/tests/test_logging.py
Expand Up @@ -229,7 +229,7 @@ def test_errno_is_specified_on_error(self):
self.assertEqual(event_dict['errno'], 111)

def test_basic_authn_type_is_bound(self):
app = self.get_test_app({'multiauth.policies': 'basicauth'})
app = self.make_app({'multiauth.policies': 'basicauth'})
app.get('/mushrooms', headers={'Authorization': 'Basic bWF0OjE='})
event_dict = logger_context()
self.assertEqual(event_dict['authn_type'], 'BasicAuth')
Expand Down
10 changes: 4 additions & 6 deletions cliquet/tests/test_views_errors.py
Expand Up @@ -98,8 +98,8 @@ def test_info_link_in_error_responses_can_be_configured(self):
'cliquet.tests.testapp.views.Mushroom._extract_filters',
side_effect=ValueError):
link = "https://github.com/mozilla-services/kinto/issues/"
app = self.get_test_app({'error_info_link': link,
'readonly': False})
app = self.make_app({'error_info_link': link,
'readonly': False})
response = app.get(self.sample_url,
headers=self.headers, status=500)
self.assertFormattedError(
Expand Down Expand Up @@ -169,8 +169,7 @@ def test_redirect_to_version(self):

def test_do_not_redirect_to_version_if_disabled_in_settings(self):
# GET on the hello view.
app = self.get_test_app({'version_prefix_redirect_enabled': False})

app = self.make_app({'version_prefix_redirect_enabled': False})
app.get('/', status=404)

def test_querystring_is_preserved_during_redirection(self):
Expand All @@ -191,8 +190,7 @@ def test_it_redirects_if_it_ends_with_a__slash_(self):
'http://localhost/v0/mushrooms')

def test_do_not_redirect_if_disabled_in_settings(self):
app = self.get_test_app({'trailing_slash_redirect_enabled': False})

app = self.make_app({'trailing_slash_redirect_enabled': False})
app.get('/', status=200)
app.get('/mushrooms/', status=404)

Expand Down

0 comments on commit 68d2c3e

Please sign in to comment.