@@ -39,7 +39,7 @@ def test_tr_link_no_target_option_in_needs():
3939 assert (
4040 tr_link (
4141 app = None ,
42- need = {"a" : "1" },
42+ need = {"id" : "1" , " a" : "1" },
4343 needs = {"x" : {"id" : "123" }},
4444 test_option = "a" ,
4545 target_option = "b" ,
@@ -56,7 +56,7 @@ def test_tr_link_no_match():
5656 assert (
5757 tr_link (
5858 app = None ,
59- need = {"a" : "1" },
59+ need = {"id" : "1" , " a" : "1" },
6060 needs = {"x" : {"b" : "2" , "id" : "123" }},
6161 test_option = "a" ,
6262 target_option = "b" ,
@@ -71,7 +71,7 @@ def test_tr_link_match():
7171 """
7272 assert tr_link (
7373 app = None ,
74- need = {"a" : "1" },
74+ need = {"id" : "1" , " a" : "1" },
7575 needs = {"x" : {"b" : "1" , "id" : "123" }},
7676 test_option = "a" ,
7777 target_option = "b" ,
@@ -82,7 +82,7 @@ def test_tr_link_none_or_empty():
8282 """
8383 'None' and empty string values are not considered as valid matches.
8484 """
85- need = {"a" : None , "b" : "" }
85+ need = {"id" : "1" , " a" : None , "b" : "" }
8686 needs = {
8787 "x" : {"c" : None , "id" : "111" },
8888 "y" : {"c" : "valid" , "id" : "222" },
@@ -108,7 +108,7 @@ def test_tr_link_regex_match():
108108 "y" : {"b" : "def456" , "id" : "222" },
109109 "z" : {"b" : "ghi789" , "id" : "333" },
110110 }
111- need = {"a" : "abc.*" }
111+ need = {"id" : "1" , " a" : "abc.*" }
112112 assert tr_link (
113113 app = None , need = need , needs = needs , test_option = "a" , target_option = "b"
114114 ) == ["111" ]
@@ -120,7 +120,19 @@ def test_tr_link_regex_no_match():
120120 does not match any target options using regular expression patterns.
121121 """
122122 needs = {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
123- need = {"a" : "xyz.*" }
123+ need = {"id" : "1" , "a" : "xyz.*" }
124+ assert (
125+ tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
126+ == []
127+ )
128+
129+
130+ def test_tr_link_skip_linking_to_itself ():
131+ """
132+ Returns an empty list when the need and needs have the same 'id'.
133+ """
134+ needs = {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
135+ need = {"id" : "111" , "a" : "abc123" }
124136 assert (
125137 tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
126138 == []
0 commit comments