The test is to ensure that when fetching the field, if it comes from the
default method, that the value returned by the default method goes through
the from_json converter before coming back to the code requesting the
field. I believe this tests that behavior because the value returned is an
int not a str although the default method is emitting a str. There's no
other way it could become an int than for the ModelType.__get__ to have
caused the cast.


On Mon, Aug 19, 2013 at 3:33 PM, Calen Pennington
<notifications@github.com>wrote:

> In xblock/test/test_runtime.py:
>
> > @@ -273,7 +273,7 @@ def __init__(self, *args, **kwargs):
> >
> >      def default(self, _key):
> >          self.default_counter += 1
> > -        return self.default_counter
> > +        return str(self.default_counter)  # str to force the from_json to do something
>
> This doesn't actually test that from_json is called. To do that, you need
> from_json to do something (create a python object, rather than just a
> list, dict, number or string, which is what json), and then to assert that
> that conversion is happening.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/edx/XBlock/pull/68/files#r5851848>
> .
>