@@ -5,31 +5,113 @@ def test_tr_link_option_not_in_need():
55    """ 
66    Return an empty string when the specified test option is missing from the need. 
77    """ 
8-     assert  tr_link (app = None , need = {}, needs = {}, test_option = "a" , target_option = "b" ) ==  "" 
8+     assert  (
9+         tr_link (app = None , need = {}, needs = {}, test_option = "a" , target_option = "b" ) ==  "" 
10+     )
11+ 
912
1013def  test_tr_link_no_target_option_in_needs ():
1114    """ 
1215    Return an empty list when the target option is missing in all items of needs. 
1316    """ 
14-     assert  tr_link (app = None , need = {"a" : "1" }, needs = {"x" : {"id" : "123" }}, test_option = "a" , target_option = "b" ) ==  []
17+     assert  (
18+         tr_link (
19+             app = None ,
20+             need = {"id" : "1" , "a" : "1" },
21+             needs = {"x" : {"id" : "123" }},
22+             test_option = "a" ,
23+             target_option = "b" ,
24+         )
25+         ==  []
26+     )
27+ 
1528
1629def  test_tr_link_no_match ():
1730    """ 
18-     Returns an empty list when no matching value for the test option is found in any of the target options within needs. 
31+     Returns an empty list when no matching value for the test option is found 
32+     in any of the target options within needs. 
1933    """ 
20-     assert  tr_link (app = None , need = {"a" : "1" }, needs = {"x" : {"b" : "2" , "id" : "123" }}, test_option = "a" , target_option = "b" ) ==  []
34+     assert  (
35+         tr_link (
36+             app = None ,
37+             need = {"id" : "1" , "a" : "1" },
38+             needs = {"x" : {"b" : "2" , "id" : "123" }},
39+             test_option = "a" ,
40+             target_option = "b" ,
41+         )
42+         ==  []
43+     )
44+ 
2145
2246def  test_tr_link_match ():
2347    """ 
2448    Returns a list of ids when there is a matching value in both need and needs. 
2549    """ 
26-     assert  tr_link (app = None , need = {"a" : "1" }, needs = {"x" : {"b" : "1" , "id" : "123" }}, test_option = "a" , target_option = "b" ) ==  ["123" ]
50+     assert  tr_link (
51+         app = None ,
52+         need = {"id" : "1" , "a" : "1" },
53+         needs = {"x" : {"b" : "1" , "id" : "123" }},
54+         test_option = "a" ,
55+         target_option = "b" ,
56+     ) ==  ["123" ]
57+ 
2758
2859def  test_tr_link_none_or_empty ():
2960    """ 
3061    'None' and empty string values are not considered as valid matches. 
3162    """ 
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" ) ==  []
63+     need  =  {"id" : "1" , "a" : None , "b" : "" }
64+     needs  =  {
65+         "x" : {"c" : None , "id" : "111" },
66+         "y" : {"c" : "valid" , "id" : "222" },
67+         "z" : {"c" : "" , "id" : "333" },
68+     }
69+     assert  (
70+         tr_link (app = None , need = need , needs = needs , test_option = "b" , target_option = "c" )
71+         ==  []
72+     )
73+     assert  (
74+         tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "c" )
75+         ==  []
76+     )
77+ 
78+ 
79+ def  test_tr_link_regex_match ():
80+     """ 
81+     Returns a list of ids when the test option value containing an asterisk (*) 
82+     correctly matches target options using regular expression patterns. 
83+     """ 
84+     needs  =  {
85+         "x" : {"b" : "abc123" , "id" : "111" },
86+         "q" : {"b" : "abc/123" , "id" : "112" },
87+         "y" : {"b" : "def456" , "id" : "222" },
88+         "z" : {"b" : "ghi789" , "id" : "333" },
89+     }
90+     need  =  {"id" : "1" , "a" : "abc.*" }
91+     assert  tr_link (
92+         app = None , need = need , needs = needs , test_option = "a" , target_option = "b" 
93+     ) ==  ["111" , "112" ]
94+ 
95+ 
96+ def  test_tr_link_regex_no_match ():
97+     """ 
98+     Returns an empty list when the test option value containing an asterisk (*) 
99+     does not match any target options using regular expression patterns. 
100+     """ 
101+     needs  =  {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
102+     need  =  {"id" : "1" , "a" : "xyz.*" }
103+     assert  (
104+         tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
105+         ==  []
106+     )
107+ 
108+ 
109+ def  test_tr_link_skip_linking_to_itself ():
110+     """ 
111+     Returns an empty list when the need and needs have the same 'id'. 
112+     """ 
113+     needs  =  {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "abc123" , "id" : "222" }}
114+     need  =  {"id" : "111" , "a" : "abc123" }
115+     assert  tr_link (
116+         app = None , need = need , needs = needs , test_option = "a" , target_option = "b" 
117+     ) ==  ["222" ]
0 commit comments