gpennington/PyMarvel — pull request #7 by fitnr (2014-06-16 22:23:04+00:00)
Title: Add and repair next, previous methods, chaining

This pull adds `next()` and `previous()` for all `DataWrapper` classes. It also simplifies the declaration of the chaining methods. In the process it fixes a bug where a call to an endpoint like `character/123/story` wouldn't have a working `next` method. The helper `_next()` and `_previous()` methods in `DataWrapper` do the logic of comparing the request to the current offset and total. A call to `next()` at the end of the result set will return `None`, likewise for `previous()` and the beginning of the result set.

To allow for simpler `next` and `previous` logic, chaining doesn't use endpoints like `character/123/story`. Instead, the equivalent `/story?characters=123` is used.

In a related change, `get_*` methods are declared once in `MarvelObject`. The repetitive declaration was circuitous and didn't properly preserve paramaters.

The `_call` method is also simplified to rely on the native functionality of the `requests` module. This means that the `json` module is no longer needed.

Argument expansion is revamped: `*args`, which were never used, have been removed. Keyword-expansion (`**kwargs`) is consistently used throughout. This fixes bugs in the `next` and `previous` methods.

Relatedly, `dict` is removed as an argument name, since that's a Python internal name.

Added an import statement to `__init__.py` to make use cleaner. The module can now be used with a simpler `from marvel import Marvel` statement.

Also fixes a bug in str_to_datetime, with an added test.

Passes all tests.