@@ -17,7 +17,7 @@ def test_tr_link_no_target_option_in_needs():
17
17
assert (
18
18
tr_link (
19
19
app = None ,
20
- need = {"a" : "1" },
20
+ need = {"id" : "1" , " a" : "1" },
21
21
needs = {"x" : {"id" : "123" }},
22
22
test_option = "a" ,
23
23
target_option = "b" ,
@@ -34,7 +34,7 @@ def test_tr_link_no_match():
34
34
assert (
35
35
tr_link (
36
36
app = None ,
37
- need = {"a" : "1" },
37
+ need = {"id" : "1" , " a" : "1" },
38
38
needs = {"x" : {"b" : "2" , "id" : "123" }},
39
39
test_option = "a" ,
40
40
target_option = "b" ,
@@ -49,7 +49,7 @@ def test_tr_link_match():
49
49
"""
50
50
assert tr_link (
51
51
app = None ,
52
- need = {"a" : "1" },
52
+ need = {"id" : "1" , " a" : "1" },
53
53
needs = {"x" : {"b" : "1" , "id" : "123" }},
54
54
test_option = "a" ,
55
55
target_option = "b" ,
@@ -60,7 +60,7 @@ def test_tr_link_none_or_empty():
60
60
"""
61
61
'None' and empty string values are not considered as valid matches.
62
62
"""
63
- need = {"a" : None , "b" : "" }
63
+ need = {"id" : "1" , " a" : None , "b" : "" }
64
64
needs = {
65
65
"x" : {"c" : None , "id" : "111" },
66
66
"y" : {"c" : "valid" , "id" : "222" },
@@ -86,7 +86,7 @@ def test_tr_link_regex_match():
86
86
"y" : {"b" : "def456" , "id" : "222" },
87
87
"z" : {"b" : "ghi789" , "id" : "333" },
88
88
}
89
- need = {"a" : "abc.*" }
89
+ need = {"id" : "1" , " a" : "abc.*" }
90
90
assert tr_link (
91
91
app = None , need = need , needs = needs , test_option = "a" , target_option = "b"
92
92
) == ["111" ]
@@ -98,7 +98,19 @@ def test_tr_link_regex_no_match():
98
98
does not match any target options using regular expression patterns.
99
99
"""
100
100
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" }
102
114
assert (
103
115
tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
104
116
== []
0 commit comments