|
40 | 40 | from docutils.parsers.rst import Directive, directives
|
41 | 41 | from sphinx.domains.python import PythonDomain
|
42 | 42 |
|
43 |
| -# from sphinx_needs.api import add_dynamic_function # TODO: JOHN |
44 |
| - |
45 | 43 | # handle python import locations for this execution
|
46 | 44 | PYTHONPATH = os.path.abspath("..")
|
47 | 45 | sys.path.insert(0, PYTHONPATH)
|
|
67 | 65 | _TUTORIAL_FILES = [
|
68 | 66 | fName for fName in bookkeepingTests.TUTORIAL_FILES if "ipynb" not in fName
|
69 | 67 | ]
|
70 |
| -TEST_RESULTS = [] |
71 |
| - |
72 |
| - |
73 |
| -def getTestResult(app, need, needs): |
74 |
| - """Dynamic function used by sphinx-needs to gather the result of a test tag.""" |
75 |
| - if not need["signature"]: |
76 |
| - return "none" |
77 |
| - |
78 |
| - # Get all the tests that match the method signature |
79 |
| - results = [ |
80 |
| - test_case["result"] |
81 |
| - for test_case in TEST_RESULTS |
82 |
| - if need["signature"] == test_case["method"] |
83 |
| - ] |
84 |
| - # Logic is as follows if there are multiple matches: |
85 |
| - # - If one is a "failure", then return "failure" |
86 |
| - # - If all are "skipped", then return "skipped" |
87 |
| - # - Otherwise, return "passed" |
88 |
| - if results: |
89 |
| - if "failure" in results: |
90 |
| - return "failure" |
91 |
| - elif "passed" in results: |
92 |
| - return "passed" |
93 |
| - else: |
94 |
| - return "skipped" |
95 |
| - |
96 |
| - # Things get a little more complicated when the test tag has a class-level signature. |
97 |
| - # Basically we have to determine if all the methods in the class passed or if any of skipped/failed. |
98 |
| - # First, gather all the results related to the class signature from the tag and categorize by method |
99 |
| - results = {} |
100 |
| - for test_case in TEST_RESULTS: |
101 |
| - if need["signature"] == test_case["class"]: |
102 |
| - if test_case["method"] in results: |
103 |
| - results[test_case["method"]].append(test_case["result"]) |
104 |
| - else: |
105 |
| - results[test_case["method"]] = [test_case["result"]] |
106 |
| - |
107 |
| - # If we haven't found the test by now, we never will |
108 |
| - if not results: |
109 |
| - return "none" |
110 |
| - |
111 |
| - # Apply logic from before for each method in the class |
112 |
| - for m, r in results.items(): |
113 |
| - if "failure" in r: |
114 |
| - results[m] = "failure" |
115 |
| - elif "passed" in r: |
116 |
| - results[m] = "passed" |
117 |
| - else: |
118 |
| - results[m] = "skipped" |
119 |
| - |
120 |
| - # Now for the class logic |
121 |
| - # - If any of the methods failed, return "failure" |
122 |
| - # - If any of the methods skipped, return "skipped" |
123 |
| - # - If all of the methods passed, return "passed" |
124 |
| - if "failure" in results.values(): |
125 |
| - return "failure" |
126 |
| - elif "skipped" in results.values(): |
127 |
| - return "skipped" |
128 |
| - else: |
129 |
| - return "passed" |
130 | 68 |
|
131 | 69 |
|
132 | 70 | class PatchedPythonDomain(PythonDomain):
|
@@ -287,31 +225,12 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):
|
287 | 225 | return name.startswith("_") or name in excludes
|
288 | 226 |
|
289 | 227 |
|
290 |
| -def getTestAcceptanceCriteria(app, need, needs): |
291 |
| - # Return title if there is not just one requirement or the linked requirement doesn't exist |
292 |
| - if len(need.get("tests", [])) != 1 or need["tests"][0] not in needs: |
293 |
| - ac = need["title"].strip() |
294 |
| - |
295 |
| - req = needs[need["tests"][0]] |
296 |
| - # Return title if there is not just one test in the requirement |
297 |
| - if len(req.get("tests_back", [])) != 1: |
298 |
| - ac = need["title"].strip() |
299 |
| - else: |
300 |
| - ac = req["acceptance_criteria"].strip() |
301 |
| - |
302 |
| - # For some reason sphinx is adding another period at the end of this, so we'll just remove it |
303 |
| - return ac[:-1] if ac[-1] == "." else ac |
304 |
| - |
305 |
| - |
306 | 228 | def setup(app):
|
307 | 229 | """Method to make `make html` generate api documentation."""
|
308 | 230 | app.connect("autodoc-skip-member", autodoc_skip_member_handler)
|
309 | 231 | app.add_domain(PatchedPythonDomain, override=True)
|
310 | 232 | app.add_directive("exec", ExecDirective)
|
311 | 233 | app.add_directive("pyreverse", PyReverse)
|
312 |
| - # add_dynamic_function(app, getTestAcceptanceCriteria, "get_test_acceptance_criteria") # TODO: JOHN |
313 |
| - # add_dynamic_function(app, getTestResult, "get_test_result") |
314 |
| - # add_dynamic_function(app, getTestAcceptanceCriteria, "get_test_acceptance_criteria") |
315 | 234 |
|
316 | 235 | # making tutorial data dir
|
317 | 236 | dataDir = pathlib.Path("user") / ".." / "anl-afci-177"
|
@@ -645,20 +564,6 @@ def setup(app):
|
645 | 564 | },
|
646 | 565 | }
|
647 | 566 |
|
648 |
| -# TODO: JOHN |
649 |
| -""" |
650 |
| -needs_global_options = { |
651 |
| - # Defaults for test tags |
652 |
| - "acceptance_criteria": ( |
653 |
| - ":ndf:`get_test_acceptance_criteria()`.", |
654 |
| - "type=='test'", |
655 |
| - ), |
656 |
| - "template": ("test", "type=='test'"), |
657 |
| - "layout": ("test_layout", "type=='test'"), |
658 |
| - "result": ("[[get_test_result()]]", "type=='test'"), |
659 |
| -} |
660 |
| -""" |
661 |
| - |
662 | 567 |
|
663 | 568 | # Formats need roles (reference to a req in text) as just the req ID
|
664 | 569 | needs_role_need_template = "{id}"
|
0 commit comments