1313)
1414
1515LOGGER = get_logger (name = __name__ )
16- BASE_COMMAND = "poetry run python apps/jira_utils/jira_information.py --verbose "
16+ BASE_COMMAND = "uv run apps/jira_utils/jira_information.py --verbose "
1717
1818
1919def test_process_jira_command_line_config_file_empty_config_token () -> None :
@@ -80,7 +80,16 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
8080 # Test case 1: Issue with no jira target versions and not resolved status
8181 ("issue1" , ["resolved" ], [], "1.0" , "file1.txt" , [], "" , "1.0" ),
8282 # Test case 2: Issue with no jira target versions, but resolved status
83- ("issue2" , ["open" ], [], "1.0" , "file2.txt" , [], "issue2 current status: open is resolved." , "1.0" ),
83+ (
84+ "issue2" ,
85+ ["open" ],
86+ [],
87+ "1.0" ,
88+ "file2.txt" ,
89+ [],
90+ "issue2 current status: open is resolved." ,
91+ "1.0" ,
92+ ),
8493 # Test case 3: Issue with no jira target versions, default resolved status
8594 ("issue3" , [], [], "" , "file3.txt" , [], "" , "1.1" ),
8695 # Test case 4: Issue with not resolved state, but matching jira target version
@@ -99,7 +108,29 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
99108 # Test case 6: Issue that would be skipped for version check because of skip
100109 ("issue6" , ["resolved" ], ["1.0" ], "1.0" , "file6.txt" , ["issue" ], "" , "1.1" ),
101110 # Test case 7: Issue that would be skipped for version check but fail resolved check
102- ("issue7" , ["open" ], ["1.0" ], "1.0" , "file6.txt" , ["issue" ], "issue7 current status: open is resolved." , "1.1" ),
111+ (
112+ "issue7" ,
113+ ["open" ],
114+ ["1.0" ],
115+ "1.0" ,
116+ "file6.txt" ,
117+ ["issue" ],
118+ "issue7 current status: open is resolved." ,
119+ "1.1" ,
120+ ),
121+ # Test case 8: Issue with unresolved state, and matching jira z target version
122+ ("issue8" , [], ["1.2.z" ], "1.2,z" , "file4.txt" , [], "" , "1.2.z" ),
123+ # Test case 9: Issue with unresolved state, and jira z target version not matching expected versions
124+ (
125+ "issue8" ,
126+ [],
127+ ["1.2.3" ],
128+ "" ,
129+ "file4.txt" ,
130+ [],
131+ "issue8 target version: 1.2.z, does not match expected version ['1.2.3']." ,
132+ "1.2.z" ,
133+ ),
103134 ],
104135 ids = [
105136 "test_no_jira_versions_no_resolved_status" ,
@@ -109,6 +140,8 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
109140 "test_no_target_versions_not_resolved_state" ,
110141 "test_skip_version_check" ,
111142 "test_skip_version_check_fail_status_check" ,
143+ "test_matching_target_z_version" ,
144+ "test_non_matching_target_z_version" ,
112145 ],
113146)
114147def test_get_jira_information (
@@ -131,8 +164,8 @@ def test_get_jira_information(
131164
132165 if jira_target_versions :
133166 mocker .patch (
134- "apps.jira_utils.jira_information.re.search " ,
135- return_value = mocker . MagicMock ( group = lambda x : test_jira_version ) ,
167+ "apps.jira_utils.jira_information.re.findall " ,
168+ return_value = [ test_jira_version ] ,
136169 )
137170 result = get_jira_information (
138171 jira_object = mock_jira ,
@@ -160,10 +193,20 @@ def test_get_jira_information(
160193@pytest .mark .parametrize (
161194 "content_and_expected" ,
162195 [
163- pytest .param ({"content" : "pytest.mark.jira(ABC-1111)" , "expected" : {"ABC-1111" }}, id = "pytest_mark_jira" ),
164- pytest .param ({"content" : "JIRA ID is jira_id=ABC-1111" , "expected" : {"ABC-1111" }}, id = "jira_id=" ),
165196 pytest .param (
166- {"content" : "JIRA URL is https://example.com/browse/ABC-1111" , "expected" : {"ABC-1111" }}, id = "jira_url="
197+ {"content" : "pytest.mark.jira(ABC-1111)" , "expected" : {"ABC-1111" }},
198+ id = "pytest_mark_jira" ,
199+ ),
200+ pytest .param (
201+ {"content" : "JIRA ID is jira_id=ABC-1111" , "expected" : {"ABC-1111" }},
202+ id = "jira_id=" ,
203+ ),
204+ pytest .param (
205+ {
206+ "content" : "JIRA URL is https://example.com/browse/ABC-1111" ,
207+ "expected" : {"ABC-1111" },
208+ },
209+ id = "jira_url=" ,
167210 ),
168211 pytest .param (
169212 {
@@ -184,6 +227,8 @@ def test_get_jira_information(
184227)
185228def test_get_jira_ids_from_file_content (content_and_expected ):
186229 jira_ids = get_jira_ids_from_file_content (
187- file_content = content_and_expected ["content" ], issue_pattern = r"([A-Z]+-[0-9]+)" , jira_url = "https://example.com"
230+ file_content = content_and_expected ["content" ],
231+ issue_pattern = r"([A-Z]+-[0-9]+)" ,
232+ jira_url = "https://example.com" ,
188233 )
189234 assert jira_ids == content_and_expected ["expected" ]
0 commit comments