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)
def test_full(self): decorations({ "class": { "snippets": ["groupable", "match"] }, "methods": { "match": { "see": ["match_all"], "link": ["http://google.com"], "manual": { "a": "https://www.php.net/manual/en/function.preg-match.php", "b": "https://t-regx.com/docs/match-first" }, "throws": ['RuntimeException'] }, "match_all": { "see": ["match"], "link": ["https://faceboob.com"], "manual": { "a": "https://www.php.net/manual/en/function.preg-match-all.php", "b": "https://t-regx.com/docs/match" }, "throws": ["Exception"] }, }, "groups": { "see": [["match", "match_all"]], "throws": [{ "methods": ["match", "match_all"], "exceptions": ["MalformedPatternException", "RuntimeSafeRegexException"] }] }, "*": { "see": ["pattern()", "Pattern::of()"], "link": [ "https://t-regx.com", "https://www.regular-expressions.info/unicode.html" ], "throws": ['SafeRegexException'] } })
def test_method_raise_throws_half_exceptions(self): self.assertRaises( SchemaError, lambda: decorations( {"methods": { "match": { "throws": [{ "exceptions": [] }] } }}))
def test_group_see_raise_on_empty_group(self): # given invalid_groups = { 'empty': [[]], 'single': [['A']], } # when for name, invalid in invalid_groups.items(): with self.subTest(name): self.assertRaises( SchemaError, lambda: decorations({"groups": { "see": invalid }}))
def test_empty_group_see(self): decorations({"groups": {"see": []}})
def test_method_throws(self): decorations({"methods": {"match": {"throws": []}}})
def test_empty_class(self): decorations({"class": {}})
def test_method_link(self): decorations({"methods": {"match": {"link": []}}})
def test_method_manual(self): decorations({"methods": {"match": {"manual": {}}}})
def test_empty_asterisk_throws(self): decorations({"*": {"see": []}})
def test_method_see(self): decorations({"methods": {"match": {"see": []}}})
def test_empty_group_throws(self): decorations({"groups": {"throws": []}})
def test_empty_asterisk_link(self): decorations({"*": {"link": []}})
def test_empty_method(self): decorations({"methods": {"match": {}}})
def test_empty(self): decorations({})
def test_empty_class_snippets(self): decorations({"class": {"snippets": []}})
def test_empty_first_level(self): decorations({"methods": {}, "groups": {}, "*": {}})
def test_empty_asterisk(self): decorations({"*": {}})
def test_empty_groups(self): decorations({"groups": {}})
def test_empty_methods(self): decorations({"methods": {}})