621 Commits

Author SHA1 Message Date
Chris Dent
683dba6a07 Add some simple docs for the LHS json path substitution.
So that there is some warning about quoting issues.
2017-07-06 16:15:09 +01:00
Chris Dent
8a031149b6 Template expansion in LHS of json path test
This change implements template substitution ($ENVIRON, $RESPONSE,
etc) in the left hand side of a response_json_paths test. This enables
testing in situations where responses may include a server side
generated identifier as the key in an object structure.

As things stand, this is the bare minimum implementation that assumes
that the test creator will be responsible for dealing with the
vargrancies of quoting that will be required in order to generate
legitimate JSON path expressions. For example if there is a uuid (with
hyphens) at $RESPONSE['$.id'] then this expression is likely to fail:

    $.nested.structure.$RESPONSE['$.id'].name: foobar

as it will evaluate to something like

    $.nested.structure.ADC8AAFC-D564-40D1-9724-7680D3C010C2.name: foobar

which _may_ be treated as an arithemtic expression by the json parser.
The test creator would need to do:

    $.nested.structure["$RESPONSE['$.id']"].name: foobar

or variants thereof to get a useful expression.

Docs to follow if this is considered an okay way to implement the
feature.

Fixes #170
2017-07-06 13:26:05 +01:00
Chris Dent
87f389688a Correct location of gnocchi repo in gnocchi tests
Gnocchi now lives on github.
2017-06-19 13:30:23 +01:00
Chris Dent
f6175cc415 Release 1.34.1
* start including a wheel in the dist
* sign the uploaded artifacts
1.34.1
2017-06-19 13:12:52 +01:00
Chris Dent
5e9e9cc991 Add configuration for uploading signed sdists and wheels
Wheels are commonly desired these days, and having them signed ought
to be done, so this adds the bits to make that possible.
2017-06-19 13:10:44 +01:00
Chris Dent
6b6acc2e53 use assertRegex not assertRegexpMatches
The latter is deprecated.
2017-05-04 19:37:17 +01:00
Chris Dent
75694c888e Update contributors list to reflect recent activity 2017-04-27 10:36:25 +01:00
Chris Dent
9d458ad165 Relase 1.34.0
- stronger types in $RESPONSE subsitutions
1.34.0
2017-04-26 21:53:35 +01:00
Chris Dent
e18a889245 Merge pull request #214 from cdent/cd/simple-coerce
Manage numerals more effectively in replacers
2017-04-26 21:16:42 +01:00
Chris Dent
bac38f8d1b Add additional test to coerce.yaml
This confirms internal strings, thanks to @justanotherdot.
2017-04-26 10:36:16 +01:00
Chris Dent
e3fb2cfa39 Manage numerals more effectively in replacers
Change the handling in response_replacer and jsonhandler.replace so
that numerals are preserved. The primary change here is that replace
does not always return a str: it returns the found data. The
remaining changes cascade from this fix.

* If the 'message' being replaced is fully the regex, don't do
  regex-based replacement (which requires a string). Instead return
  the new value.

* Do template replacing on test data _before_ dumping it to a string.
  This allows the small 'message' replacements described in the previous
  point.

* Assure we can recurse through lists, not just dicts, when
  replacing in data structures.

In the pull request at #206 there is a different mode of coercing
and preserving data types operates by adding a coerce method to
content handlers. While inspecting this it seemed like it might be
too complex, so this alternate option has been explored. This might
work, or perhaps a hybrid of the two.

The coerce.yaml file from #206 was copied here and adapted to fit
the different assumptions that are made in this change. Some of the
assumptions in 206 don't map well to YAML handling of literal data
formats.
2017-04-23 17:52:33 +01:00
Ryan James Spencer
ac0243df46 Add optional test param for custom content handlers (#212)
Add optional `test` param for custom content handlers

This resolves #211.

`multipart/form-data` transmission requires modifying the `Content-Type`
header with a `boundary` section identifier, and as such a custom
content handler would not have previously had access to the running test
case it was working on. This should hopefully be useful for other custom
content handlers in the future.
2017-04-02 17:37:58 +01:00
Chris Dent
ba236801d0 Remove .testrepository/times.dbm each test run
This overcomes a long standing bug in the testr tool: it doesn't
specify a dbm type to use, using a default which changes from
one python version to another (depending on build settings). It
is also unable to identify what was already used (which would be a
normal thing to do) and use that. Instead it just fails awkwardly.

The workaround is to remove the times.db file before each run
because it is not relevant.
1.33.0
2017-03-21 09:56:40 +00:00
Chris Dent
b4e738b808 release 1.33.0
* count and poll use substitions
* build_tests param keyword
* fixes to prefix handling
* fixes to reading utf8 encoding on disk data
2017-03-21 09:26:09 +00:00
Chris Dent
37ee5babbd Enforce type of response/content-handler test data
Each of the response and content handlers has an expected type that
the test data should be in (in the YAML file). For example
response_strings should be a list. These changes add some
enforcement of those types, without which it is possible to (rarely)
get false positives when using a str value where a list value is
expected and the assertions using that value use 'in'.

Fixes #209
2017-03-20 19:03:33 +00:00
Chris Dent
867042bc99 Merge pull request #208 from justanotherdot/verbose-option
Add verbose option to `build_tests`
2017-03-15 11:30:45 +00:00
Ryan Spencer
8e5e68563a Make verbose accept additional valid strings 2017-03-15 09:15:03 +11:00
Chris Dent
bb7867aed3 Merge pull request #207 from cdent/fix-150
Allow substitutions in count and delay
2017-03-14 13:41:41 +00:00
Ryan Spencer
0d37fc10d4 Add verbose option to build_tests 2017-03-14 12:08:39 +11:00
Chris Dent
564d099702 Allow substitutions in count and delay
Since we know that count must always be an int and delay can be
either and int or float, the yaml data is passed through
replace_template and then cast to int or float explicitly.

This is different previous solution which tries to rely on the
casting happening in replace_template. With the new coerce style of
numbers-in-data handling being developed in #206 that strategy won't
work. In any case, this way is more contained and explicit.

Fixes #150
2017-03-11 17:48:34 +00:00
Chris Dent
31163305a0 Merge pull request #205 from cdent/fix-165
Avoid duplicating prefix when re-using urls
2017-03-03 14:07:29 +00:00
Chris Dent
22bef30f81 Fix prefix handling for relative urls
Basically we just remove the trailing prefix / and leading path /
and then join with /.
2017-02-24 12:43:26 -05:00
Chris Dent
cc79b5fd98 Add a test for a relative link and add a comment
The comment explains how this is a pragmatic fix that could be done
in a more robust way by changing data structures to distinguish
between server and gabbi test generated urls.
2017-02-24 11:59:35 -05:00
Chris Dent
561c76ccc5 Avoid duplicating prefix when re-using urls
If a reponse includes an absolute link, re-using that link as the
url in a subsequent test when a prefix is being used in the tests
can result in a 404 because the prefix will be duplicated.

This change ensures that the prefix will not be duplicated if the
URL already begins with the prefix.

Fixes #165
2017-02-22 10:38:02 -05:00
Chris Dent
637a48983a Merge pull request #204 from cdent/play-with-str
Unicode content from disk must become bytes
2017-02-17 10:44:01 +00:00
Chris Dent
27927de577 Ensure that $HOME is in passenv
$ENVIRON['HOME'] is being used in utf8.txt
2017-02-16 17:35:22 +00:00
Chris Dent
c697b533e0 Unicode content from disk must become bytes
While trying to figure out some tests for the fix in #203 it became
clear that the handling of encoded-on-disk-but-textual content
when using <@ to load content was not sufficiently robust in both
python 2 and 3.

We want to load content to become unicode so that it is used
internally correctly, for example in the replace_template handling
used for substitutions, but when an HTTP request is made the content
must become whatever the versioned equivalent of bytes is.

Therefore the code has been changed to load non_binary content and
decode it to six.text_type, do replace_template on it, and then turn
the body, if it is not already bytes, into bytes.

This is verified by adjusting data.json to have some utf8 in it and
adding and loading a utf8.txt example file.
2017-02-16 17:21:54 +00:00
Chris Dent
d8fe9f801b Release 1.32.0
- Improved error reporting when using multiple files with gabbi-run
1.32.0
2017-02-06 13:28:42 +00:00
Chris Dent
a1c7c82e69 Merge pull request #201 from cdent/gabbi-run-fail-info
Adjust runner to track test suite failures
2017-02-06 13:08:00 +00:00
Chris Dent
cade01d299 Minor comment clarification
Use quote marks to indicate literal string.
2017-02-06 12:52:16 +00:00
Chris Dent
f0bacce539 Adjust runner to track test suite failures
Change the reporter used by gabbi-run so that it provides a more
complete test name in its output, using the id() of the test. This
will include the name of the yaml file.

Also track failures per input file and provide a summary of which
files contained failures (if any) at the end.

Both of these changes were done in the simplest way possible so
there is probably considerably room for improvement now that the
concept has been proven.

Fixes #181
2017-02-02 17:49:27 +00:00
Chris Dent
fb9a001db7 Release 1.31.0
- capture exceptions in start_fixture as test errors
1.31.0
2017-01-17 15:22:28 +00:00
Chris Dent
2c302422db Merge pull request #200 from cdent/bug-199
Handle exceptions when starting fixtures
2017-01-17 15:14:57 +00:00
Chris Dent
493c58f76d Handle exceptions when starting fixtures
Some test runners will swallow exceptions and tracebacks that happen
during the start_fixture method of a Fixture. This can lead to a
great deal of confusion when creating new fixtures. This change
ensures that the traceback is made available by forcing an error to
be reported on the first test in the test suite using the fixture.
Additional detail can be found in the comment associated with the
change.

The added test_suite file tests this change by creating a suite with
two tests that use a fixture that will raise an exception in
start_fixture. The test confirms that the right test is errored,
that both are skipped and that the traceback includes expected
information.

Fixes #199
2017-01-17 14:17:16 +00:00
Chris Dent
3e450b1d37 Add a bit of test running arcana to the faq
Running just one dynamically generated test can be a bit confusing
so some advice is added to the faq. At some point this should
probably be intergrated into the mainline docs.
2017-01-12 13:44:48 +00:00
Chris Dent
3ea4c3b60d Fix verbose printing of json bodies
If a request is content-type application/json, but the body is
empty, a request to verbosely print the body of the test will
cause a JSONdecoder error.
1.30.2
2017-01-06 19:18:31 +00:00
Chris Dent
c755719d1e Force removal of the .tox when doing make clean
The addition of the gnocchi tox job means there is a git repo in there
after that tox job has run, which has files that will not delete without
a force.
1.30.1
2017-01-06 16:19:03 +00:00
Chris Dent
64c2e60496 Release 1.30.1
- application/xml is now considered non binary
2017-01-06 16:09:52 +00:00
Tom Viner
2bafddfb09 add application/xml.* as non-binary 2017-01-06 15:29:21 +00:00
Chris Dent
6671e5d4d1 Remove FAQ entry about pytest warnings
The issue was resolved and for older versions, or use of the old style
there is an explanation of how to deal with things in loader.rst.
2017-01-04 11:30:19 +00:00
Chris Dent
d22e643bb6 Use newer style of stating method in example.yaml
It is more readable and the more commonly used style now.
2017-01-04 11:27:26 +00:00
Chris Dent
3592a19446 Merge pull request #197 from cdent/test-gnocchi
Add optional testing of current gabbi with current gnocchi
2017-01-02 14:45:58 +00:00
Chris Dent
aa20c2862f Add optional testing of current gabbi with current gnocchi
Gnocchi is a big consumer of gabbi so it is useful to run the gabbi
tests in gnocchi against the new gabbi to raise red flags where there
are issues.
2017-01-02 14:27:30 +00:00
Chris Dent
d80441307b Merge pull request #196 from cdent/py36-support
Py36 support
2017-01-02 12:57:37 +00:00
Chris Dent
174077b487 Try using a matrix to support multiple pythons 2017-01-02 12:39:41 +00:00
Chris Dent
807375aeb0 Try using python 3.5 to run all the tests
Otherwise python 3.5 is not found.
2017-01-02 12:15:55 +00:00
Chris Dent
d956d6fbe5 Add testing infrastructure for python 3.6
3.6 was released near the end of 2016 so ought to get it in the
testing loop. Local tests are passing, so this commit checks travis.
2017-01-02 12:07:59 +00:00
Chris Dent
2b9774ad0e release 1.30.0
- Add support for $HISTORY substitution
1.30.0
2016-12-30 16:11:58 +00:00
Chris Dent
15ef8d712e Add docs for the $HISTORY feature
To prepare the 1.30.0 release.
2016-12-30 15:48:33 +00:00
Chris Dent
efbaf13629 Minor test format doc improvements
Turn a paragraph identified as a note into an rst-styled note.

Clarify how the 'url' key is required.
2016-12-30 15:14:27 +00:00