@@ -49,6 +49,8 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
4949 "version_string_not_targeted_jiras" : version_string_not_targeted_jiras ,
5050 "target_versions" : target_versions ,
5151 "skip_project_ids" : skip_projects ,
52+ "user" : "" ,
53+ "cloud" : False ,
5254 },
5355 )
5456 result = process_jira_command_line_config_file (
@@ -60,6 +62,8 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
6062 version_string_not_targeted_jiras ,
6163 target_versions ,
6264 skip_projects ,
65+ user = "" ,
66+ cloud = False ,
6367 )
6468 assert result == {
6569 "url" : url ,
@@ -69,10 +73,195 @@ def test_process_jira_command_line_config_file_valid_config(mocker):
6973 "not_targeted_version_str" : version_string_not_targeted_jiras ,
7074 "target_versions" : target_versions ,
7175 "skip_project_ids" : skip_projects ,
76+ "user" : "" ,
77+ "cloud" : False ,
7278 }
7379 mock_get_util_config .assert_called_once ()
7480
7581
82+ def test_process_jira_command_line_config_file_cloud_valid (mocker ):
83+ config_file_path = "/path/to/config"
84+ url = "https://example.com"
85+ token = "1234567890"
86+ user = "test@example.com"
87+
88+ mocker .patch (
89+ "apps.jira_utils.jira_information.get_util_config" ,
90+ return_value = {
91+ "url" : url ,
92+ "token" : token ,
93+ "cloud" : True ,
94+ "user" : user ,
95+ },
96+ )
97+ result = process_jira_command_line_config_file (
98+ config_file_path = config_file_path ,
99+ url = url ,
100+ token = token ,
101+ issue_pattern = "*" ,
102+ resolved_statuses = ["RESOLVED" ],
103+ version_string_not_targeted_jiras = "v1.*" ,
104+ target_versions = ["v2" ],
105+ skip_projects = [],
106+ user = user ,
107+ cloud = True ,
108+ )
109+ assert result ["cloud" ] is True
110+ assert result ["user" ] == user
111+
112+
113+ def test_process_jira_command_line_config_file_cloud_missing_user (mocker ):
114+ config_file_path = "/path/to/config"
115+ url = "https://example.com"
116+ token = "1234567890"
117+
118+ mocker .patch (
119+ "apps.jira_utils.jira_information.get_util_config" ,
120+ return_value = {
121+ "url" : url ,
122+ "token" : token ,
123+ },
124+ )
125+ with pytest .raises (SystemExit ):
126+ process_jira_command_line_config_file (
127+ config_file_path = config_file_path ,
128+ url = url ,
129+ token = token ,
130+ issue_pattern = "*" ,
131+ resolved_statuses = ["RESOLVED" ],
132+ version_string_not_targeted_jiras = "v1.*" ,
133+ target_versions = ["v2" ],
134+ skip_projects = [],
135+ user = "" ,
136+ cloud = True ,
137+ )
138+
139+
140+ def test_process_cloud_from_config_when_cli_not_passed (mocker ):
141+ mocker .patch (
142+ "apps.jira_utils.jira_information.get_util_config" ,
143+ return_value = {"url" : "https://example.com" , "token" : "tok" , "cloud" : True , "user" : "u@e.com" },
144+ )
145+ result = process_jira_command_line_config_file (
146+ config_file_path = "/path" ,
147+ url = "https://example.com" ,
148+ token = "tok" ,
149+ issue_pattern = "*" ,
150+ resolved_statuses = [],
151+ version_string_not_targeted_jiras = "" ,
152+ target_versions = [],
153+ skip_projects = [],
154+ user = "u@e.com" ,
155+ cloud = None ,
156+ )
157+ assert result ["cloud" ] is True
158+ assert result ["user" ] == "u@e.com"
159+
160+
161+ def test_process_cloud_defaults_false_when_not_in_config (mocker ):
162+ mocker .patch (
163+ "apps.jira_utils.jira_information.get_util_config" ,
164+ return_value = {"url" : "https://example.com" , "token" : "tok" },
165+ )
166+ result = process_jira_command_line_config_file (
167+ config_file_path = "/path" ,
168+ url = "https://example.com" ,
169+ token = "tok" ,
170+ issue_pattern = "*" ,
171+ resolved_statuses = [],
172+ version_string_not_targeted_jiras = "" ,
173+ target_versions = [],
174+ skip_projects = [],
175+ user = "" ,
176+ cloud = None ,
177+ )
178+ assert result ["cloud" ] is False
179+
180+
181+ def test_process_cloud_from_config_missing_user_exits (mocker ):
182+ mocker .patch (
183+ "apps.jira_utils.jira_information.get_util_config" ,
184+ return_value = {"url" : "https://example.com" , "token" : "tok" , "cloud" : True },
185+ )
186+ with pytest .raises (SystemExit ):
187+ process_jira_command_line_config_file (
188+ config_file_path = "/path" ,
189+ url = "https://example.com" ,
190+ token = "tok" ,
191+ issue_pattern = "*" ,
192+ resolved_statuses = [],
193+ version_string_not_targeted_jiras = "" ,
194+ target_versions = [],
195+ skip_projects = [],
196+ user = "" ,
197+ cloud = None ,
198+ )
199+
200+
201+ def test_process_user_from_config_fallback (mocker ):
202+ mocker .patch (
203+ "apps.jira_utils.jira_information.get_util_config" ,
204+ return_value = {"url" : "https://example.com" , "token" : "tok" , "user" : "config@example.com" , "cloud" : True },
205+ )
206+ result = process_jira_command_line_config_file (
207+ config_file_path = "/path" ,
208+ url = "https://example.com" ,
209+ token = "tok" ,
210+ issue_pattern = "*" ,
211+ resolved_statuses = [],
212+ version_string_not_targeted_jiras = "" ,
213+ target_versions = [],
214+ skip_projects = [],
215+ user = "" ,
216+ cloud = True ,
217+ )
218+ assert result ["user" ] == "config@example.com"
219+ assert result ["cloud" ] is True
220+
221+
222+ def test_process_cloud_false_explicit_ignores_config (mocker ):
223+ mocker .patch (
224+ "apps.jira_utils.jira_information.get_util_config" ,
225+ return_value = {"url" : "https://example.com" , "token" : "tok" , "cloud" : True },
226+ )
227+ result = process_jira_command_line_config_file (
228+ config_file_path = "/path" ,
229+ url = "https://example.com" ,
230+ token = "tok" ,
231+ issue_pattern = "*" ,
232+ resolved_statuses = [],
233+ version_string_not_targeted_jiras = "" ,
234+ target_versions = [],
235+ skip_projects = [],
236+ user = "" ,
237+ cloud = False ,
238+ )
239+ assert result ["cloud" ] is False
240+
241+
242+ def test_process_server_mode_default (mocker ):
243+ mocker .patch (
244+ "apps.jira_utils.jira_information.get_util_config" ,
245+ return_value = {"url" : "https://example.com" , "token" : "tok" },
246+ )
247+ result = process_jira_command_line_config_file (
248+ config_file_path = "/path" ,
249+ url = "https://example.com" ,
250+ token = "tok" ,
251+ issue_pattern = "([A-Z]+-[0-9]+)" ,
252+ resolved_statuses = ["resolved" ],
253+ version_string_not_targeted_jiras = "vfuture" ,
254+ target_versions = [],
255+ skip_projects = [],
256+ user = "" ,
257+ cloud = False ,
258+ )
259+ assert result ["cloud" ] is False
260+ assert result ["user" ] == ""
261+ assert result ["url" ] == "https://example.com"
262+ assert result ["token" ] == "tok"
263+
264+
76265@pytest .mark .parametrize (
77266 "test_params" ,
78267 [
0 commit comments