コード例 #1
0
 def test_json_schema_merge_extends(self):
     # Arraneg
     parent_schema = {"id": "parentschema",
         "additionalProperties": False,
         "properties": {"parent_prop": {"type": "string"}}
     }
     child_schema = {"id": "childschema",
         "additionalProperties": False,
         "extends": parent_schema,
         "properties": {"child_prop": {"type": "string"}}
     }
     child2_schema = {"id": "childschema",
         "additionalProperties": False,
         "extends": child_schema,
         "properties": {"child_prop2": {"type": "string"}}
     }
     child3_schema = {"id": "childschema",
         "additionalProperties": False,
         "extends": child_schema,
         "properties": {
             "child_prop3": {"type": "string"},
             "child_extend": {
                 "extends": parent_schema,
                 "properties": {
                     "sub_child":{
                         "type": "string"
                     }
                 }
             }
         }
     }
     
     parent_schema_copy = copy.copy(parent_schema)
     child_schema_copy = copy.copy(child_schema)
     child2_schema_copy = copy.copy(child2_schema)
     child3_schema_copy = copy.copy(child3_schema)
     
     # Act
     utils.json_schema_merge_extends(parent_schema_copy)
     utils.json_schema_merge_extends(child_schema_copy)
     utils.json_schema_merge_extends(child2_schema_copy)
     utils.json_schema_merge_extends(child3_schema_copy)
     
     # Assert
     self.assertEqual(child_schema_copy["properties"].get("parent_prop", None), 
                     parent_schema["properties"]["parent_prop"])
     self.assertEqual(child2_schema_copy["properties"].get("parent_prop", None), 
                     parent_schema["properties"]["parent_prop"])
     self.assertEqual(child2_schema_copy["properties"].get("parent_prop", None), 
                     child_schema["properties"]["child_prop"])
     self.assertEqual(child3_schema_copy["properties"].get("parent_prop", None), 
                     parent_schema["properties"]["parent_prop"])
     self.assertEqual(child3_schema_copy["properties"].get("parent_prop", None), 
                     child_schema["properties"]["child_prop"])
     self.assertEqual(child3_schema_copy["properties"]["child_extend"]["properties"].get("parent_prop", None), 
                     parent_schema["properties"]["parent_prop"])
コード例 #2
0
 def _save_schema(self, response, uri, callback):        
     self.__CACHE__[uri] = json.loads(response.body)
     # Work around that 'extends' is not supported in validictory
     json_schema_merge_extends(self.__CACHE__[uri], self.__CACHE__)
     callback(self.__CACHE__[uri])
コード例 #3
0
 def _load_schema(self, uri):
     resp, content = self._http.request(uri, "GET")
     self.__CACHE__[uri] = json.loads(content)
     # Work around that 'extends' is not supported in validictory
     json_schema_merge_extends(self.__CACHE__[uri], self.__CACHE__)
     return self.__CACHE__[uri]
コード例 #4
0
ファイル: models.py プロジェクト: christina-n/unis
 def _save_schema(self, response, uri, callback):
     self.__CACHE__[uri] = json.loads(response.body)
     # Work around that 'extends' is not supported in validictory
     json_schema_merge_extends(self.__CACHE__[uri], self.__CACHE__)
     callback(self.__CACHE__[uri])
コード例 #5
0
ファイル: models.py プロジェクト: christina-n/unis
 def _load_schema(self, uri):
     resp, content = self._http.request(uri, "GET")
     self.__CACHE__[uri] = json.loads(content)
     # Work around that 'extends' is not supported in validictory
     json_schema_merge_extends(self.__CACHE__[uri], self.__CACHE__)
     return self.__CACHE__[uri]