|
| 1 | +from sphinxcontrib.test_reports.functions import tr_link |
| 2 | + |
| 3 | + |
| 4 | +def test_tr_link_option_not_in_need(): |
| 5 | + """ |
| 6 | + Return an empty string when the specified test option is missing from the need. |
| 7 | + """ |
| 8 | + assert tr_link(app=None, need={}, needs={}, test_option="a", target_option="b") == "" |
| 9 | + |
| 10 | +def test_tr_link_no_target_option_in_needs(): |
| 11 | + """ |
| 12 | + Return an empty list when the target option is missing in all items of needs. |
| 13 | + """ |
| 14 | + assert tr_link(app=None, need={"a": "1"}, needs={"x": {"id": "123"}}, test_option="a", target_option="b") == [] |
| 15 | + |
| 16 | +def test_tr_link_no_match(): |
| 17 | + """ |
| 18 | + Returns an empty list when no matching value for the test option is found in any of the target options within needs. |
| 19 | + """ |
| 20 | + assert tr_link(app=None, need={"a": "1"}, needs={"x": {"b": "2", "id": "123"}}, test_option="a", target_option="b") == [] |
| 21 | + |
| 22 | +def test_tr_link_match(): |
| 23 | + """ |
| 24 | + Returns a list of ids when there is a matching value in both need and needs. |
| 25 | + """ |
| 26 | + assert tr_link(app=None, need={"a": "1"}, needs={"x": {"b": "1", "id": "123"}}, test_option="a", target_option="b") == ["123"] |
| 27 | + |
| 28 | +def test_tr_link_none_or_empty(): |
| 29 | + """ |
| 30 | + 'None' and empty string values are not considered as valid matches. |
| 31 | + """ |
| 32 | + need = {"a": None, "b": ""} |
| 33 | + needs = {"x": {"c": None, "id": "111"}, "y": {"c": "valid", "id": "222"}, "z": {"c": "", "id": "333"}} |
| 34 | + assert tr_link(app=None, need=need, needs=needs, test_option="b", target_option="c") == [] |
| 35 | + assert tr_link(app=None, need=need, needs=needs, test_option="a", target_option="c") == [] |
0 commit comments