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
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.
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
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.
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.
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.
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.
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.
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.
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.
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
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.