def test_get_json_object(self):
        x = JsonObject(foo=5, bar=True)
        y = JsonObject(bar=x)

        self.assertTrue(y.get_json_object("bar") == x)

        # Test the default value is returned if field is missing.
        self.assertTrue(x.get_json_object("none", default_value=x) == x)

        # Test returns none if missing.
        self.assertEquals(x.get_json_object("none", none_if_missing=True), None)

        # Raise an exception when field is missing.
        self.assertRaises(JsonMissingFieldException, y.get_json_object, "none")

        # Raise an exception if field is not JsonObject
        self.assertRaises(JsonConversionException, x.get_json_object, "foo")
    def test_get_json_object(self):
        x = JsonObject(foo=5, bar=True)
        y = JsonObject(bar=x)

        self.assertTrue(y.get_json_object("bar") == x)

        # Test the default value is returned if field is missing.
        self.assertTrue(x.get_json_object("none", default_value=x) == x)

        # Test returns none if missing.
        self.assertEquals(x.get_json_object("none", none_if_missing=True), None)

        # Raise an exception when field is missing.
        self.assertRaises(JsonMissingFieldException,
                          y.get_json_object, "none")

        # Raise an exception if field is not JsonObject
        self.assertRaises(JsonConversionException,
                          x.get_json_object, "foo")