@@ -5,31 +5,101 @@ def test_tr_link_option_not_in_need():
5
5
"""
6
6
Return an empty string when the specified test option is missing from the need.
7
7
"""
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
+
9
12
10
13
def test_tr_link_no_target_option_in_needs ():
11
14
"""
12
15
Return an empty list when the target option is missing in all items of needs.
13
16
"""
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 = {"a" : "1" },
21
+ needs = {"x" : {"id" : "123" }},
22
+ test_option = "a" ,
23
+ target_option = "b" ,
24
+ )
25
+ == []
26
+ )
27
+
15
28
16
29
def test_tr_link_no_match ():
17
30
"""
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.
19
33
"""
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 = {"a" : "1" },
38
+ needs = {"x" : {"b" : "2" , "id" : "123" }},
39
+ test_option = "a" ,
40
+ target_option = "b" ,
41
+ )
42
+ == []
43
+ )
44
+
21
45
22
46
def test_tr_link_match ():
23
47
"""
24
48
Returns a list of ids when there is a matching value in both need and needs.
25
49
"""
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 = {"a" : "1" },
53
+ needs = {"x" : {"b" : "1" , "id" : "123" }},
54
+ test_option = "a" ,
55
+ target_option = "b" ,
56
+ ) == ["123" ]
57
+
27
58
28
59
def test_tr_link_none_or_empty ():
29
60
"""
30
61
'None' and empty string values are not considered as valid matches.
31
62
"""
32
63
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" ) == []
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
+ "y" : {"b" : "def456" , "id" : "222" },
87
+ "z" : {"b" : "ghi789" , "id" : "333" },
88
+ }
89
+ need = {"a" : "abc.*" }
90
+ assert tr_link (
91
+ app = None , need = need , needs = needs , test_option = "a" , target_option = "b"
92
+ ) == ["111" ]
93
+
94
+
95
+ def test_tr_link_regex_no_match ():
96
+ """
97
+ Returns an empty list when the test option value containing an asterisk (*)
98
+ does not match any target options using regular expression patterns.
99
+ """
100
+ needs = {"x" : {"b" : "abc123" , "id" : "111" }, "y" : {"b" : "def456" , "id" : "222" }}
101
+ need = {"a" : "xyz.*" }
102
+ assert (
103
+ tr_link (app = None , need = need , needs = needs , test_option = "a" , target_option = "b" )
104
+ == []
105
+ )
0 commit comments