64 Commits

Author SHA1 Message Date
Vladyslav Drok
6dc053296f Change flask restful module name
It moved from flask.ext.restful to flask_restful.

Change-Id: I160e665976b13a263ee04a0472b67c0fd99e218d
2018-06-26 19:59:32 +03:00
Chris Dent
1440eeb13b Fix (some) tests for modern flask and pep8
Somewhere along the way, WSME and flask/werkzeug have got out of sync
and tests have started failing. Since there aren't regular contributions
to WSME we don't catch these changes, so this may have happened months
or years ago.

I have adjusted tests to attempt to account for what I can, but one test
fails to work so I have marked it as an xfail. It works correctly with
werkzeug 1.13.x but not later. Since WSME is in something worse than
maintenance mode, I'm not inclined to fix this.

pep8/flake8 in python3 is more strict than python. The gate now
runs the pep8 jobs using python3 by default, so the local jobs
should as well. This changes the job and also fixes the new problems it
points out.

There are other failures, but they are present in master as well, so
leaving that for other changes.

Change-Id: I57ae0405e0d6ddba0bb1dac93020fb08a0fc7c89
2018-04-09 13:24:20 +01:00
Vladyslav Drok
1670793bfe Print exceptions raised from from_param methods
This makes debugging the problems easier.

Change-Id: I285d8176b8cfb0cdf1e9cecd8ae5a0a7f0f109e7
2016-12-23 14:09:16 +02:00
Victor Stinner
6560133d79 Port test_cornice to Python 3
* Use byte strings for HTTP body
* Remove debug print()
* tox.ini: add cornice-py3 test environment

Note: It looks like it doesn't work to inherit commands from cornice
into cornice-py3 because cornice commands use the substitution string
{posargs}.

Change-Id: Iaed39babc7ee9877d443c47c2f4b21b2e98b5181
2016-03-08 10:31:21 +01:00
Stéphane Bisinger
32456d3e47 Replace deprecated assertEquals with assertEqual
Unit tests were still using the deprecated assertEquals instead of
assertEqual. This removes all mentions of assertEquals to use the new name and
be compatible with the OpenStack Style Guidelines.

Closes-Bug: #1454766
Partial-Bug: #1446692
Change-Id: Ieb90a334a0d0e91845d20a3e4ea4697307ed3f2a
2015-05-13 18:35:41 +02:00
Chris Dent
78d6b89d18 Enable real testing of python 3.4
The gate 34 tests were not running any tests because there was no
tox target. This changes tox-tmpl.ini (and the resulting tox.ini) to
add support for python 34 and remove support for anything that is
not py34 or py27-based.

To make the python3 tox environments work, the remote zip of a suds
fork has been replaced with suds-jurko, a relatively modern fork of
the original suds that supports python2 and 3.

Some tests needed to be fixed to deal with two main problems:

* reponse bodies being bytes
* Exceptions not having a .message attribute (.args[0] is used
  instead)
* the test_flask tests were not being run for python3, they are now
* wsmeext/sphinxext.py intermittently fails due to the dictionary
  changing size in flight, getting the keys prior to iteration fixes
  it

Both 27 and 34 should be running 420 tests as of this commit.

Change-Id: I837c249714fd957790ea84aa2fd9ad994a39c5ea
2015-04-28 14:59:33 +01:00
Lucas Alvares Gomes
de877d2cc8 Pecan: Make it possible to use the Response to return a non-default return type
This patch is extending the Response object and the Pecan extension
to make it possible to return a non-default return type (just like it
already supports retuning a non default status code).

This is useful when the return code of a function is 204 (No Response) for
that case we automatically set the return_type to be None and guarantee
that the response body is empty and the content-lentgh is 0. Which if
not done can cause tools consuming the API to misbehave.

Change-Id: I629c3e2d5dc169154e5af044f1b8f804e4b87e23
2015-04-01 14:44:46 +01:00
Christophe de Vienne
292c556808 Make the flask adapter working with flask.ext.restful
Change-Id: I71d875f6579799b2881f76859fa88226dfea9b2b
2014-11-11 09:45:09 +01:00
Ryan Petrello
26a6acdadd Add support for manually specifying supported content types in @wsmeexpose.
Closes-bug: #1271317
Change-Id: Ia28a912f4444a6ff77b1feaf2ea6440b0c738e86
2014-09-24 21:04:52 -04:00
Ryan Petrello
7cee58bce9 Fix broken sphinx tests.
Change-Id: I2c2046b4ef31c78731f25f3b8e579b05ca0953fb
2014-09-23 13:25:09 -04:00
gordon chung
baa816c820 fix errors/warnings in tests
sphinxext tests reference paths that don't exist. this patch
corrects it.

Change-Id: I6a9355a53e2f72de7eab17fc117334843ff8d369
2014-08-27 22:09:07 +01:00
arati.mahimane
1a918b5bba Fix error: variable 'kw' referenced before assignment
Change-Id: Ife95d74bf645687dc4595b16434c88ee874c2f95
Closes-bug: #1311742
2014-04-29 10:34:36 -05:00
James Page
1bf6317a3c Drop description from 403 flask test case
Older versions of werkzeug pass the description parameter back
in the description.  As the description is never actually validated
in the test case, dropping it seems OK.

Change-Id: Icd547113d8fe918f35a97c4a5de220b3aaace5cd
Closes-Bug: 1242486
2013-10-20 18:23:40 -07:00
Jenkins
b011b2c83f Merge "Validate body when using Pecan" 2013-10-14 14:19:23 +00:00
Jenkins
5b283a613f Merge "Return a ClientSideError if unable to convert data" 2013-10-14 14:18:41 +00:00
Julien Danjou
b67405d486 Validate body when using Pecan
This makes sure that when the body is decoded we run the validation
process on it.

Fixes-Bug: #1220678

Change-Id: I765a6ce8c8097ef0e0a734804242e9fcee4ffbcf
2013-10-09 17:14:02 +02:00
Julien Danjou
8a0c4e66c9 Return a ClientSideError if unable to convert data
This makes thing works at least for Pecan.

Change-Id: I7b02813258d9b8c2eea13e4215a3d711ec2e56ed
2013-10-09 16:08:22 +02:00
Yuriy Zveryanskyy
9546c10250 Add custom error code to ClientSideError
Added custom error status code for ClientSideError
exception instead of hardcoded value 400.
Fixed case when user exception with client error code
formatted as server error.
Pecan extension fixed.

Change-Id: I2663db0aa88538b722eb2783d130585b0fc2335b
2013-10-09 16:59:40 +03:00
Julien Danjou
cce52e1431 pecantest: remove useless config.py
Change-Id: I3370715d12209528fe63d5bd9bb7b7e78c935351
2013-09-26 17:59:56 +02:00
Julien Danjou
abcdd7affa Include Pecan tests in default Python environment
- Makes sure we always run Pecan test and that there's no regression.
  There's no real need to split them out as they are not invasive.
  Also that reduces the number of environment a bit.
- This also fixes Pecan tests on python2.6
- This also fixes Pecan tests on python3.3
- This also enables Pecan tests on python3.2

Change-Id: I57070b0bd785fb3d445f432973f15825abccbdd5
2013-09-26 17:37:03 +02:00
Ryan Petrello
62725bb773 Add improved support for HTTP response codes in cornice apps.
Change-Id: I35efe85794e761877edd06722952292a3cac5d85
2013-09-16 12:07:55 -04:00
Ryan Petrello
0aba00b1ef Add improved support for HTTP response codes in TG 1.x apps.
Change-Id: I829ab360e13ae88a47e810079c739eac1d925139
2013-09-06 15:06:35 -04:00
Ryan Petrello
d8a70a300e Add improved support for HTTP response codes in flask apps.
Change-Id: If9894b262c58c597d7f7ae0cf6cb5de6783d364d
2013-09-06 12:59:31 -04:00
119Vik
651ad18bdd Fix for returned status code and .gitignore
For this purposes I added addiitional processing of original
exceptions at wsme/wsmeext/pecan.py. For exception's validation
special validator was added to wsme/wsmeext/utils.py. Also
functionality was reworked to be compatible with python3.3

Fixes bug#1214073
Change-Id: Ib1cd0b274bda11f62298848ebcd55b3f6641757c
2013-08-28 18:03:30 +03:00
Christophe de Vienne
f9fe028eff Fix issue #11 in the pecan adapter 2013-08-02 14:04:43 +02:00
Christophe de Vienne
8b235ef79a Add a unittest to reproduce issue #11 2013-08-02 13:24:06 +02:00
Angus Salkeld
4c581aac48 Test changing the default status_code in pecan 2013-04-30 15:26:06 +10:00
Angus Salkeld
6e5cb63d7a Add a test to make sure we can use the Response from pecan 2013-04-30 15:15:32 +10:00
Christophe de Vienne
6b1a94b092 wsmeext.cornice now handle errors properly 2013-04-17 17:51:44 +02:00
Christophe de Vienne
72d245ad5f Tests cornice resource 2013-04-17 16:50:17 +02:00
Christophe de Vienne
cffcee226c Pecan adapter: Debug mode (which returns the exception tracebacks to the
client) can be enabled by the pecan application configuration.
2013-04-16 15:42:23 +02:00
Christophe de Vienne
83bc4b596b A new HostRequest type can be used to have the host framework request object passed to the exposed functions 2013-04-02 16:19:30 +02:00
Christophe de Vienne
c1f08c40db Create some (incomplete) tests for the cornice adapter and fix it 2013-03-28 23:30:06 +01:00
Endre Karlson
6f9bb4d14f Add tests and fix check ordering in flask.py 2013-03-28 12:44:52 +00:00
Endre Karlson
1e699bf143 Backed out changeset d6facd75c051 2013-03-28 12:36:27 +00:00
Endre Karlson
575efa2a7c Fix typo 2013-03-28 12:31:18 +00:00
Christophe de Vienne
d6e36463b1 Fix array parameters support in the Flask adapter 2013-03-28 11:24:15 +01:00
Christophe de Vienne
bfd1bfb4ff Various fixes for the flask adapter 2013-03-26 14:29:18 +01:00
Endre Karlson
07adf31cd7 Add more tests 2013-03-26 11:11:11 +00:00
Christophe de Vienne
e5a5465bb6 Fix the serverside error test 2013-03-25 16:23:23 +01:00
Christophe de Vienne
78c3328506 Test & fix Server-side errors 2013-03-25 16:07:02 +01:00
Christophe de Vienne
737b794e07 New flask adapter + test (run "tox -e flask" to test) 2013-03-25 12:40:45 +01:00
Christophe de Vienne
d71b762ae3 Add a test to reproduce the bug reported by Endre Karlson 2013-02-15 14:33:25 +01:00
Christophe de Vienne
9ee2d2f9a2 Add a test for the body= parameter of wsexpose
--HG--
extra : rebase_source : fc9479a0aa0de8485440a70e86971666fea56fb8
2013-02-15 14:05:49 +01:00
Christophe de Vienne
03b038b6bf Merge in wsme-soap 2013-01-24 22:26:42 +01:00
Christophe de Vienne
8736089dc9 Moved non-core features to the wsmeext namespace package
--HG--
rename : wsme/cornice.py => wsmeext/cornice.py
rename : wsme/pecan.py => wsmeext/pecan.py
rename : wsme/sphinxext.py => wsmeext/sphinxext.py
rename : wsme/tg1.py => wsmeext/tg1.py
rename : wsme/tg11.py => wsmeext/tg11.py
rename : wsme/tg15.py => wsmeext/tg15.py
2013-01-17 13:15:25 +01:00
Christophe de Vienne
bd184770a3 Pecan adapter is now at 100% of code coverage 2013-01-17 12:01:55 +01:00
Christophe de Vienne
4cf2c37ae1 Improve code coverage for the TG 1.5 adapter 2013-01-17 11:26:06 +01:00
Christophe de Vienne
d346db3e8c Code cleaning + better code coverage of the TG1.1 adapter 2013-01-17 11:18:58 +01:00
Christophe de Vienne
5ca0186863 Fix the tg 1.x tests
--HG--
extra : rebase_source : 2a19a7022e1d99042de403a5c310dda994b5650a
2013-01-16 21:40:45 +01:00