[Grok-dev] why are REST and JSON tests so different?
Brandon Craig Rhodes
brandon at rhodesmill.org
Sat Jan 10 10:35:02 EST 2009
As I finish up the Grok docstrings (and it's been a very educational
experience, I'm glad I volunteered), it is time for me to tackle the
REST and JSON components. I would have expected the two services to be
very similar: both allow incoming HTTP requests to be multiplexed across
a set of Python methods (REST doing the multiplexing by HTTP method, and
JSON by the function call name in the HTTP data), and both of them -
unlike the simpler (and easier-to-document!) XML-RPC mechanism - allow
the use of layers in combination with them.
My confusion comes from three sources. I don't mean the big overarching
confusion that happens on any first encounter with Zope 3 layers, that
someone-was-thinking-completely-backwards-here feeling. :-) I mean three
smaller and more specific things.
Please note that these are real questions, Brandon-wants-to-be-more-
educated-because-he-doesn't-understand questions! These are not
Brandon-is-sure-you-did-something-wrong-and-is-disguising-his-design-
criticism-as-a-question questions!
So:
* The JSON tests never seem to actually test a real, live method call
over a browser request to show that things actually work. All of the
tests in `tests/json` seem to either test bare components (as in
`json_layers.py`) or test various sorts of errors that programmers can
make in setting up their `grok.JSON` subclass. I don't actually see a
test of whether a JSON HTTP request actually works. :-)
* Nearly all JSON tests are unit tests, while nearly all REST tests are
functional tests. I am not sure what the logic was behind testing
them each in this way; it seems, again, like both would have wanted
unit tests for anything that checks whether the classes works, and
then several ftests that actually throw HTTP requests at a little Grok
web application and see if the answers come back correctly.
* When REST wants to test layers it uses URLs with ++'s all over them,
as I would expect. When JSON tests layers, it does lots of object
adaptation. Mightn't we want to standardize on one way or the other
for testing layers/skins with both of them, so that a similar feature
in two places in Grok has similar-looking tests in both places?
--
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list