@@ -17,7 +17,7 @@ def test_tr_link_no_target_option_in_needs():
1717 assert (
1818 tr_link (
1919 app = None ,
20- need = {"a" : "1" },
20+ need = {"id" : "1" , " a" : "1" },
2121 needs = {"x" : {"id" : "123" }},
2222 test_option = "a" ,
2323 target_option = "b" ,
@@ -34,7 +34,7 @@ def test_tr_link_no_match():
3434 assert (
3535 tr_link (
3636 app = None ,
37- need = {"a" : "1" },
37+ need = {"id" : "1" , " a" : "1" },
3838 needs = {"x" : {"b" : "2" , "id" : "123" }},
3939 test_option = "a" ,
4040 target_option = "b" ,
@@ -49,7 +49,7 @@ def test_tr_link_match():
4949 """
5050 assert tr_link (
5151 app = None ,
52- need = {"a" : "1" },
52+ need = {"id" : "1" , " a" : "1" },
5353 needs = {"x" : {"b" : "1" , "id" : "123" }},
5454 test_option = "a" ,
5555 target_option = "b" ,
@@ -60,7 +60,7 @@ def test_tr_link_none_or_empty():
6060 """
6161 'None' and empty string values are not considered as valid matches.
6262 """
63- need = {"a" : None , "b" : "" }
63+ need = {"id" : "1" , " a" : None , "b" : "" }
6464 needs = {
6565 "x" : {"c" : None , "id" : "111" },
6666 "y" : {"c" : "valid" , "id" : "222" },
@@ -86,7 +86,7 @@ def test_tr_link_regex_match():
8686 "y" : {"b" : "def456" , "id" : "222" },
8787 "z" : {"b" : "ghi789" , "id" : "333" },
8888 }
89- need = {"a" : "abc.*" }
89+ need = {"id" : "1" , " a" : "abc.*" }
9090 assert tr_link (
9191 app = None , need = need , needs = needs , test_option = "a" , target_option = "b"
9292 ) == ["111" ]
@@ -98,7 +98,19 @@ def test_tr_link_regex_no_match():
9898 does not match any target options using regular expression patterns.
9999 """
100100 needs = {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
101- need = {"a" : "xyz.*" }
101+ need = {"id" : "1" , "a" : "xyz.*" }
102+ assert (
103+ tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
104+ == []
105+ )
106+
107+
108+ def test_tr_link_skip_linking_to_itself ():
109+ """
110+ Returns an empty list when the need and needs have the same 'id'.
111+ """
112+ needs = {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
113+ need = {"id" : "111" , "a" : "abc123" }
102114 assert (
103115 tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
104116 == []
0 commit comments