Ejemplo n.º 1
0
 def test_merge_simple_dicts_with_precedence(self):
     a = {'a': 'value', 'ab': 'overwritten'}
     b = {'b': 'other value', 'ab': 'keep'}
     assert utils.merge(a, b) == {
         'a': 'value',
         'b': 'other value',
         'ab': 'keep'
     }
Ejemplo n.º 2
0
 def test_merge_simple_dicts_with_precedence(self):
     a = {"a": "value", "ab": "overwritten"}
     b = {"b": "other value", "ab": "keep"}
     assert utils.merge(a, b) == {
         "a": "value",
         "b": "other value",
         "ab": "keep"
     }
Ejemplo n.º 3
0
 def wrapper(func):
     doc = {
         'responses': {
             code: (description, [fields]) if as_list else
             (description, fields)
         },
         '__mask__': kwargs.get(
             'mask', True
         ),  # Mask values can't be determined outside app context
     }
     func.__apidoc__ = merge(getattr(func, '__apidoc__', {}), doc)
     return marshal_with(fields, ordered=self.ordered, **kwargs)(func)
Ejemplo n.º 4
0
 def test_recursions_with_empty(self):
     a = {}
     b = {
         'b': 'other value',
         'ab': 'keep',
         'nested_b': {
             'b': 'nested'
         },
         'nested_a_b': {
             'b': 'b only',
             'ab': 'keep'
         }
     }
     assert utils.merge(a, b) == b
Ejemplo n.º 5
0
 def test_recursions_with_empty(self):
     a = {}
     b = {
         "b": "other value",
         "ab": "keep",
         "nested_b": {
             "b": "nested"
         },
         "nested_a_b": {
             "b": "b only",
             "ab": "keep"
         },
     }
     assert utils.merge(a, b) == b
Ejemplo n.º 6
0
 def _handle_api_doc(self, cls, doc):
     if doc is False:
         cls.__apidoc__ = False
         return
     ##unshortcut_params_description(doc)
     ##handle_deprecations(doc)
     ##for key in 'get', 'post', 'put', 'delete', 'options', 'head', 'patch':
     ##    if key in doc:
     ##        if doc[key] is False:
     ##            continue
     ##        unshortcut_params_description(doc[key])
     ##        handle_deprecations(doc[key])
     ##        if 'expect' in doc[key] and not isinstance(doc[key]['expect'], (list, tuple)):
     ##            doc[key]['expect'] = [doc[key]['expect']]
     cls.__apidoc__ = merge(getattr(cls, '__apidoc__', {}), doc)
Ejemplo n.º 7
0
 def test_recursions(self):
     a = {
         'a': 'value',
         'ab': 'overwritten',
         'nested_a': {
             'a': 'nested'
         },
         'nested_a_b': {
             'a': 'a only',
             'ab': 'overwritten'
         }
     }
     b = {
         'b': 'other value',
         'ab': 'keep',
         'nested_b': {
             'b': 'nested'
         },
         'nested_a_b': {
             'b': 'b only',
             'ab': 'keep'
         }
     }
     assert utils.merge(a, b) == {
         'a': 'value',
         'b': 'other value',
         'ab': 'keep',
         'nested_a': {
             'a': 'nested'
         },
         'nested_b': {
             'b': 'nested'
         },
         'nested_a_b': {
             'a': 'a only',
             'b': 'b only',
             'ab': 'keep'
         }
     }
Ejemplo n.º 8
0
 def test_recursions(self):
     a = {
         "a": "value",
         "ab": "overwritten",
         "nested_a": {
             "a": "nested"
         },
         "nested_a_b": {
             "a": "a only",
             "ab": "overwritten"
         },
     }
     b = {
         "b": "other value",
         "ab": "keep",
         "nested_b": {
             "b": "nested"
         },
         "nested_a_b": {
             "b": "b only",
             "ab": "keep"
         },
     }
     assert utils.merge(a, b) == {
         "a": "value",
         "b": "other value",
         "ab": "keep",
         "nested_a": {
             "a": "nested"
         },
         "nested_b": {
             "b": "nested"
         },
         "nested_a_b": {
             "a": "a only",
             "b": "b only",
             "ab": "keep"
         },
     }
Ejemplo n.º 9
0
 def test_merge_simple_dicts_without_precedence(self):
     a = {'a': 'value'}
     b = {'b': 'other value'}
     assert utils.merge(a, b) == {'a': 'value', 'b': 'other value'}
Ejemplo n.º 10
0
 def test_merge_simple_dicts_without_precedence(self):
     a = {"a": "value"}
     b = {"b": "other value"}
     assert utils.merge(a, b) == {"a": "value", "b": "other value"}