diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-04-04 19:23:04 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-04-04 19:23:04 -0500 |
commit | 5c2ece7401723486d76ea0fcd2f99ba4d1002504 (patch) | |
tree | a71a2bf9b15bd2805e344362e0bd265d7a124910 /mediagoblin/tests/test_http_callback.py | |
parent | e11c62a0efeb053f71f8ab0793c7399ce8b0758d (diff) | |
download | mediagoblin-5c2ece7401723486d76ea0fcd2f99ba4d1002504.tar.lz mediagoblin-5c2ece7401723486d76ea0fcd2f99ba4d1002504.tar.xz mediagoblin-5c2ece7401723486d76ea0fcd2f99ba4d1002504.zip |
Switch test_app generation over to use py.test fixtures.
By doing this, we can take advantage of py.test's ability to create
temporary directories that are then cleaned up later during testing.
This helps for sandboxing things.
This also involves a ton of changes:
- Changing the get_app stuff appropriately, getting rid of the
setup_fresh_app decorator
- Making said fixture
- Switching over a billion tests to use it
Diffstat (limited to 'mediagoblin/tests/test_http_callback.py')
-rw-r--r-- | mediagoblin/tests/test_http_callback.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/mediagoblin/tests/test_http_callback.py b/mediagoblin/tests/test_http_callback.py index f7249229..e2c85d0d 100644 --- a/mediagoblin/tests/test_http_callback.py +++ b/mediagoblin/tests/test_http_callback.py @@ -20,28 +20,27 @@ from urlparse import urlparse, parse_qs from mediagoblin import mg_globals from mediagoblin.tools import processing -from mediagoblin.tests.tools import get_app, fixture_add_user +from mediagoblin.tests.tools import fixture_add_user from mediagoblin.tests.test_submission import GOOD_PNG from mediagoblin.tests import test_oauth as oauth class TestHTTPCallback(object): - def setup(self): - self.app = get_app(dump_old_app=False) + def _setup(self, test_app): self.db = mg_globals.database self.user_password = u'secret' self.user = fixture_add_user(u'call_back', self.user_password) - self.login() + self.login(test_app) - def login(self): - self.app.post('/auth/login/', { + def login(self, testapp): + testapp.post('/auth/login/', { 'username': self.user.username, 'password': self.user_password}) - def get_access_token(self, client_id, client_secret, code): - response = self.app.get('/oauth/access_token', { + def get_access_token(self, testapp, client_id, client_secret, code): + response = testapp.get('/oauth/access_token', { 'code': code, 'client_id': client_id, 'client_secret': client_secret}) @@ -50,13 +49,15 @@ class TestHTTPCallback(object): return response_data['access_token'] - def test_callback(self): + def test_callback(self, test_app): ''' Test processing HTTP callback ''' + self._setup(test_app) self.oauth = oauth.TestOAuth() - self.oauth.setup() + self.oauth._setup(test_app) - redirect, client_id = self.oauth.test_4_authorize_confidential_client() + redirect, client_id = self.oauth.test_4_authorize_confidential_client( + test_app) code = parse_qs(urlparse(redirect.location).query)['code'][0] @@ -65,11 +66,11 @@ class TestHTTPCallback(object): client_secret = client.secret - access_token = self.get_access_token(client_id, client_secret, code) + access_token = self.get_access_token(test_app, client_id, client_secret, code) callback_url = 'https://foo.example?secrettestmediagoblinparam' - res = self.app.post('/api/submit?client_id={0}&access_token={1}\ + res = test_app.post('/api/submit?client_id={0}&access_token={1}\ &client_secret={2}'.format( client_id, access_token, |