21 Commits

Author SHA1 Message Date
Chris Dent
4b82d0ddc7 Clean up content-type parsing
Some of the places in which not_binary was being called were
not guarded in a way that made sure that the content-type being
sent to not_binary was just a media-type (without charset etc).

A parse_content_type method was extracted from the
extract_content_type method so that both a headers dict or a simple
header value could be parsed.

This seemed more generic and contractual than making not_binary
extract if required.

Fixes #158
2016-07-03 14:11:12 -04:00
Chris Dent
b6d2689e15 Enable a 'url' arg to build_tests (#153)
The value of url overrides host, port and prefix if it is set.
This will make some live testing scenarios more straightforward.

Fixes #50
2016-06-13 20:10:24 +01:00
Chris Dent
e2964930a9 Runner cleanup (#141)
Extract methods from the run() method in runner.py to make the
processing of information easier to test and easier to assemble.
Most methods were kept in runner.py but loading yaml was
extracted to utils.py where it can be reused by driver.py.
2016-06-06 11:42:05 +01:00
Chris Dent
3d04e979c2 Get gabbi working with IPv6 addresses
According to rfc 2732 an IPv6 address in a url needs to be enclosed
in [] (e.g. http://[::1]/foobar). Gabbi was not doing this. Instead
it was passing host information directly to its URL generation
routine and just using it. When doing tests against real servers
running on ipv6, this results in failures.

The changes here try to do the bare minumum to get the right results
without changing the create_url method too much. It's likely that in
some future version of gabbi we will want to change a lot here (the
current orientation towards hosts and ports instead of URLs is the
result of the wsgi-intercept integration) but for now we want to
keep the change limited.

I hate myself for the mocks in test_runner. A clear sign of bad
abstraction in runner.py, however this is not the place to be
changing that. Another item for the later list.

Fixes #136
2016-06-01 13:35:26 +01:00
Chris Dent
e31f9b4f62 Make pylint a little happier
Import ordering, parenthesis and docstring adjustments.
2016-05-07 14:00:37 +01:00
Chris Dent
ac7a013362 Make some pylint encouraged cleanups
Mostly doc strings.

Writing the docstring for assert_in_or_print_output exposed a typo
in the environment variable being read to get the max length check.
I suspect nobody was using this, so just changing it.
2015-10-14 10:54:00 +01:00
Chris Dent
3a74f64f83 Lessen complexity in create_url
It was a bit hard to read and tested as having too much cyclomatic
complexity.

Also, so that it is more clear what 'type' prefix is, always default
it to '' instead of None where possible.
2015-10-08 17:54:00 +01:00
Chris Dent
1305efaa88 Extract create_url to utils
The case._parse_url method was overly complex and merged several
different pieces of functionality. This change extracts the part
that creates a fully qualified url when the url is not already fully
qualified.

It also moves query_parameter extension to its own method.

The resulting code is still complex (and has further changes
forthcoming) but is moving in the right direction.
2015-10-08 16:39:09 +01:00
Chris Dent
239b49797f Provide an environ to override isatty checking.
For those times when you are piping through less or sending data
over a FIFO.

(Conditional upon review)
2015-08-10 21:44:34 +01:00
Chris Dent
2b0df54fb8 Extract color output handling for reuse
Move the colorize stuff from the reporter to utils, use it in
VerboseHttp.

What's there now is merely a demonstration of capabilities, to be
resolved by further discussion.
2015-08-10 20:43:18 +01:00
Chris Dent
9e1172fc83 Class level PREFIX and BLACKLIST defaults
This makes the class extensible while containing the info in a
visible place.

Also, make sure that the prefix is being called wherever it is
actually used, not using static strings.

Renamed decode_content to decode_response_content for (ever so)
slightly more meaningful name.

More to come.
2015-08-10 20:23:50 +01:00
Chris Dent
b770462670 Proof of concept for increased verbosity
This add support for the verbose setting to take any single value from
the set: True, False, all, headers, body. "all" and "True" mean show
both headers and body (and anything else we might come up with later).

The code works by making the VerboseHttp class contain all the magic
for verbosity, rather than splitting it in different places. The logic
for making decisions is too messy and could do with some refactoring.

There's logic in place for adding future color and different output
locations (because that was how I made sure the class we encapsulating
well).

A start at getting #69 in shape, but some distance from done.
2015-08-09 18:13:05 +01:00
Chris Dent
7b0128648a Confirm additional json derived content types work
application/json-home sets a new form of derived media types, but we
should be aware of it. The code is now adjusted to accept it and
anything else that startswith application/json.

Also media types are case insensitive so JSON decoding should
account for that.
2015-08-04 18:34:10 +01:00
Chris Dent
27eb9b2d89 Make sure content_type is stripped of whitespace.
Otherwise the not_binary method will not match.

I considered stripping in not_binary but I think it is better that
it be strict in what it accepts.
2015-07-22 20:11:00 +01:00
Chris Dent
59ad05476a Be more robust in processing content-type charset
We can't rely on there being only one parameter in the content-type,
so we need to do some processing to extract exactly the charset.

Thanks to @ravichandrasadineni for pointing out the problem and
providing a possible solution. This solution differs slightly from
his, but is the same in spirit.

The simple_wsgi app has been updated to return a content-type which
will exercise this code.

Fixes #66
2015-07-22 20:01:03 +01:00
Chris Dent
1f0b1f7542 Be ambiguous about copyright
The part that matters is the license not who or what holds it.
2015-07-20 13:57:05 +01:00
Chris Dent
a0b8bea5ca Fix pep8 in ConnectionRefused changes
Make travis check pep8.
2015-07-14 11:01:36 +01:00
FND
7bb2cca716 Fix compatibility with Python 3.2 and below 2015-07-14 11:30:12 +02:00
Chris Dent
24c9071930 cleanup more author tags 2015-05-26 22:57:09 +01:00
Chris Dent
75394fbf61 Add verbose reporting of request and response
In normal testing setups it is not possible to see the requests and
responses being made. If a test is set to 'verbose: True' then the
test request info and the httplib2 request and response data will be
produced to STDOUT.
2015-04-27 14:07:17 +01:00
Chris Dent
753ab77a52 Cleanup case module for increased clarity.
* Functions moved to utils module
* http request moved to own method
* redundant data assignment of response and output rationalized
2015-03-08 15:01:09 +00:00