[Python-modules-commits] [webtest] 01/04: Import webtest_2.0.21.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Mon Jul 18 20:09:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository webtest.
commit 79b24abc73100f22a129dd59cfa6ccf1eec14077
Author: Piotr Ożarowski <piotr at debian.org>
Date: Mon Jul 18 21:46:11 2016 +0200
Import webtest_2.0.21.orig.tar.gz
---
CHANGELOG.rst | 10 ++++++++
PKG-INFO | 3 ++-
WebTest.egg-info/PKG-INFO | 3 ++-
WebTest.egg-info/requires.txt | 1 +
setup.py | 7 +++++-
tests/test_authorisation.py | 18 +++++++++++++++
tests/test_response.py | 14 +++++++++++
tests/test_utils.py | 7 ++++++
tox.ini | 54 ++++---------------------------------------
webtest/app.py | 6 ++++-
webtest/forms.py | 2 ++
webtest/response.py | 5 +++-
webtest/utils.py | 3 +--
13 files changed, 77 insertions(+), 56 deletions(-)
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index ba6e5c9..673b71e 100755
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,16 @@
News
====
+2.0.21 (2016-04-12)
+-------------------
+
+- PR #154 Allow Bearer auth
+
+- PR #147,#148 Take care of REFERER when using form.submit(), .click() and
+ .clickbutton()
+
+- PR #145 Allow to override content-type when using json methods
+
2.0.20 (2015-11-03)
-------------------
diff --git a/PKG-INFO b/PKG-INFO
index 10ecde1..cc82867 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: WebTest
-Version: 2.0.20
+Version: 2.0.21
Summary: Helper to test WSGI applications
Home-page: http://webtest.pythonpaste.org/
Author: Gael Pasgrimaud
@@ -32,3 +32,4 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/WebTest.egg-info/PKG-INFO b/WebTest.egg-info/PKG-INFO
index 10ecde1..cc82867 100644
--- a/WebTest.egg-info/PKG-INFO
+++ b/WebTest.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: WebTest
-Version: 2.0.20
+Version: 2.0.21
Summary: Helper to test WSGI applications
Home-page: http://webtest.pythonpaste.org/
Author: Gael Pasgrimaud
@@ -32,3 +32,4 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/WebTest.egg-info/requires.txt b/WebTest.egg-info/requires.txt
index 4c199bb..bf30d50 100644
--- a/WebTest.egg-info/requires.txt
+++ b/WebTest.egg-info/requires.txt
@@ -13,6 +13,7 @@ mock
PasteDeploy
WSGIProxy2
pyquery
+unittest2
[tests:python_version=="2.6"]
unittest2
diff --git a/setup.py b/setup.py
index f6911f8..8e3d367 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ import sys
from setuptools import setup
from setuptools import find_packages
-version = '2.0.20'
+version = '2.0.21'
install_requires = [
'six',
@@ -21,7 +21,11 @@ tests_require = [
if sys.version_info[0:2] < (2, 7):
install_requires.append('ordereddict')
+
+if sys.version_info[0:2] <= (2, 7):
tests_require.append('unittest2')
+else:
+ tests_require.append('unittest2py3k')
setup(name='WebTest',
@@ -41,6 +45,7 @@ setup(name='WebTest',
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5",
],
keywords='wsgi test unit tests web',
author='Ian Bicking',
diff --git a/tests/test_authorisation.py b/tests/test_authorisation.py
index f1f03d9..5cdc1e7 100644
--- a/tests/test_authorisation.py
+++ b/tests/test_authorisation.py
@@ -33,9 +33,27 @@ class TestAuthorization(unittest.TestCase):
app.authorization = None
self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ)
+ def test_bearer_authorization(self):
+ app = self.callFUT()
+ authorization = ('Bearer', '2588409761fcfa3e378bff4fb766e2e2')
+ app.authorization = authorization
+
+ self.assertIn('HTTP_AUTHORIZATION', app.extra_environ)
+ self.assertEquals(app.authorization, authorization)
+
+ resp = app.get('/')
+ resp.mustcontain('HTTP_AUTHORIZATION: Bearer 2588409761fcfa3e378bff4fb766e2e2')
+ header = resp.request.environ['HTTP_AUTHORIZATION']
+ self.assertTrue(header.startswith('Bearer '))
+
+ app.authorization = None
+ self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ)
+
def test_invalid(self):
app = self.callFUT()
self.assertRaises(ValueError, app.set_authorization, ())
self.assertRaises(ValueError, app.set_authorization, '')
self.assertRaises(ValueError, app.set_authorization, ('Basic', ''))
self.assertRaises(ValueError, app.set_authorization, ('Basic', ()))
+ self.assertRaises(ValueError, app.set_authorization, ('Bearer', ()))
+ self.assertRaises(ValueError, app.set_authorization, ('Bearer', []))
diff --git a/tests/test_response.py b/tests/test_response.py
index 05ec180..f73a281 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -259,6 +259,20 @@ class TestResponse(unittest.TestCase):
app.get('/').clickbutton, buttonid='button3'
)
+ def test_referer(self):
+ app = webtest.TestApp(links_app)
+ resp = app.get('/').click('Foo')
+ self.assertIn('Referer', resp.request.headers)
+ self.assertEqual(resp.request.headers['Referer'], 'http://localhost/')
+
+ resp = app.get('/').clickbutton(buttonid='button1')
+ self.assertIn('Referer', resp.request.headers)
+ self.assertEqual(resp.request.headers['Referer'], 'http://localhost/')
+
+ resp = app.get('/one_forms/').form.submit()
+ self.assertIn('Referer', resp.request.headers)
+ self.assertEqual(resp.request.headers['Referer'], 'http://localhost/one_forms/')
+
def test_xml_attribute(self):
app = webtest.TestApp(links_app)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index da174a3..4301d33 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -104,6 +104,13 @@ class json_methodTest(unittest.TestCase):
'params': json.dumps({'a': 'b'}),
'upload_files': None}))
+ def test_json_method_request_respects_content_type_argument(self):
+ self.assertEquals(self.mock.foo_json('url', params={'a': 'b'}, c='c', content_type='application/vnd.api+json;charset=utf-8'),
+ ('FOO', 'url', {'content_type': 'application/vnd.api+json;charset=utf-8',
+ 'c': 'c',
+ 'params': json.dumps({'a': 'b'}),
+ 'upload_files': None}))
+
def test_json_method_doc(self):
self.assertIn('FOO request', self.mock.foo_json.__doc__)
self.assertIn('TestApp.foo', self.mock.foo_json.__doc__)
diff --git a/tox.ini b/tox.ini
index b183e0d..241e7a3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,19 +1,12 @@
[tox]
-envlist=py33,py34,py26,py27,coverage
+skip_missing_interpreters=true
+envlist=py26,py27,py33,py34,py35,coverage
[testenv]
-commands =
- {envbindir}/python --version
- {envbindir}/pip freeze
- {envbindir}/nosetests --with-coverage --with-xunit --xunit-file=nosetests-{envname}.xml []
- {envbindir}/coverage xml -o coverage-{envname}.xml
setenv =
LC_ALL=C
LANG=C
- SELENIUM_DRIVER=firefox
COVERAGE_FILE=.coverage.{envname}
-
-[common]
deps =
nose<1.3.0
webtest[tests]
@@ -23,49 +16,12 @@ deps =
BeautifulSoup4
PasteDeploy
WSGIProxy2
-
-[PY2]
-deps =
- unittest2
-
-[PY3]
-deps =
- unittest2py3k
-
-[testenv:py26]
-deps =
- {[common]deps}
- {[PY2]deps}
- ordereddict
-
-[testenv:py27]
-deps =
- {[common]deps}
- {[PY2]deps}
-
-[testenv:pypy]
-deps =
- {[common]deps}
- {[PY2]deps}
-
-[testenv:py32]
-deps =
- {[common]deps}
- {[PY3]deps}
-
-[testenv:py33]
-deps =
- {[common]deps}
- {[PY3]deps}
-
-[testenv:py34]
-deps =
- {[common]deps}
- {[PY3]deps}
commands =
{envbindir}/python --version
{envbindir}/pip freeze
- {envbindir}/nosetests
+ py{26,27,33}: {envbindir}/nosetests --with-coverage --with-xunit --xunit-file=nosetests-{envname}.xml []
+ py{26,27,33}: {envbindir}/coverage xml -o coverage-{envname}.xml
+ py{34,35}: {envbindir}/nosetests
[testenv:coverage]
deps =
diff --git a/webtest/app.py b/webtest/app.py
index 8110ed8..b3012cd 100644
--- a/webtest/app.py
+++ b/webtest/app.py
@@ -11,6 +11,7 @@ from __future__ import unicode_literals
import os
import re
+import sys
import json
import random
import fnmatch
@@ -195,7 +196,7 @@ class TestApp(object):
self.authorization_value = value
if value is not None:
invalid_value = (
- "You should use a value like ('Basic', ('user', 'password'))"
+ "You should use a value like ('Basic', ('user', 'password')) OR ('Bearer', 'token')"
)
if isinstance(value, (list, tuple)) and len(value) == 2:
authtype, val = value
@@ -204,6 +205,9 @@ class TestApp(object):
val = ':'.join(list(val))
val = b64encode(to_bytes(val)).strip()
val = val.decode('latin1')
+ elif authtype == 'Bearer' and val and \
+ isinstance(val, (str, text_type)):
+ val = val.strip()
else:
raise ValueError(invalid_value)
value = str('%s %s' % (authtype, val))
diff --git a/webtest/forms.py b/webtest/forms.py
index e64c6f7..9ff0a17 100644
--- a/webtest/forms.py
+++ b/webtest/forms.py
@@ -603,6 +603,8 @@ class Form(object):
fields = self.submit_fields(name, index=index, submit_value=value)
if self.method.upper() != "GET":
args.setdefault("content_type", self.enctype)
+ extra_environ = args.setdefault('extra_environ', {})
+ extra_environ.setdefault('HTTP_REFERER', str(self.response.request.url))
return self.response.goto(self.action, method=self.method,
params=fields, **args)
diff --git a/webtest/response.py b/webtest/response.py
index bca7c6f..3952079 100644
--- a/webtest/response.py
+++ b/webtest/response.py
@@ -161,6 +161,8 @@ class TestResponse(webob.Response):
id=linkid,
href_pattern=href,
index=index, verbose=verbose)
+ extra_environ = extra_environ or {}
+ extra_environ.setdefault('HTTP_REFERER', str(self.request.url))
return self.goto(str(found_attrs['uri']), extra_environ=extra_environ)
def clickbutton(self, description=None, buttonid=None, href=None,
@@ -178,7 +180,8 @@ class TestResponse(webob.Response):
id=buttonid,
href_pattern=href,
index=index, verbose=verbose)
- return self.goto(str(found_attrs['uri']))
+ extra_environ = {'HTTP_REFERER': str(self.request.url)}
+ return self.goto(str(found_attrs['uri']), extra_environ=extra_environ)
def _find_element(self, tag, href_attr, href_extract,
content, id,
diff --git a/webtest/utils.py b/webtest/utils.py
index e6b1cf8..3eb7f90 100644
--- a/webtest/utils.py
+++ b/webtest/utils.py
@@ -26,12 +26,11 @@ def json_method(method):
"""
def wrapper(self, url, params=NoDefault, **kw):
- content_type = 'application/json'
+ kw.setdefault('content_type', 'application/json')
if params is not NoDefault:
params = dumps(params, cls=self.JSONEncoder)
kw.update(
params=params,
- content_type=content_type,
upload_files=None,
)
return self._gen_request(method, url, **kw)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/webtest.git
More information about the Python-modules-commits
mailing list