Пример #1
0
 def test_full(self):
     declarations({
         "match": {
             "param": {
                 "pattern": "string",
                 "subject": "string",
                 "flags": {
                     'bit-sum':
                     ["PREG_OFFSET_CAPTURE", "PREG_UNMATCHED_AS_NULL"]
                 },
                 "matches": ["string[]", "optional", "&ref"],
                 "offset": ["int", "optional", "&ref"]
             },
             "return-type": "int"
         },
         "match_all": {
             "param": {
                 "pattern": "string",
                 "subject": "string",
                 "matches": ["array[]", "optional", "&ref"],
                 "flags": {
                     'bit-sum': [
                         "PREG_PATTERN_ORDER", "PREG_SET_ORDER",
                         "PREG_OFFSET_CAPTURE", "PREG_UNMATCHED_AS_NULL"
                     ]
                 },
                 "offset": ["int", "optional", "&ref"]
             },
             "template": {
                 "a": ["string", "string[]"]
             },
             "return-type": "int"
         },
     })
Пример #2
0
def build_details(summaries: dict = None,
                  params: dict = None,
                  links: dict = None) -> dict:
    validate.definitions(summaries) if summaries else {}
    validate.declarations(params) if params else {}
    validate.decorations(links) if links else {}

    dictionaries = merge_dictionaries([
        build_params(params or {}),
        build_links(links or {}),
        build_summaries(summaries or {})
    ],
                                      allow_override=False)
    return polyfill_methods(dictionaries)
Пример #3
0
 def test_raise_on_invalid_param(self):
     self.assertRaises(SchemaError,
                       lambda: declarations({"match": {
                           "param": {
                               "a": 2
                           }
                       }}))
Пример #4
0
 def test_raise_on_invalid_template_param_list(self):
     self.assertRaises(
         SchemaError,
         lambda: declarations({"match": {
             "template": {
                 "T": [2]
             }
         }}))
Пример #5
0
 def test_empty_template(self):
     declarations({"match": {"template": {"T": []}}})
Пример #6
0
 def test_single_type_template(self):
     declarations({"match": {"template": {"T": "string"}}})
Пример #7
0
 def test_empty_param(self):
     declarations({"match": {"param": {}}})
Пример #8
0
 def test_empty_first_level(self):
     declarations({"match": {}})
Пример #9
0
 def test_empty(self):
     declarations({})