feat: Improve macOS app chooser functionality and enhance drag operation success criteria
Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions
Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions
This commit is contained in:
parent
cbd8ed0186
commit
d6f4140947
3 changed files with 80 additions and 20 deletions
|
|
@ -206,11 +206,31 @@ class TestMainWindowOpenWith:
|
|||
test_file = sample_config.allowed_roots[0] / "open_with_macos.txt"
|
||||
test_file.write_text("test")
|
||||
|
||||
class _Result:
|
||||
call_count = [0] # Use list to make it mutable in nested function
|
||||
|
||||
class _AppChooseResult:
|
||||
returncode = 0
|
||||
|
||||
stdout = "TextEdit" # Simulated chosen app name
|
||||
|
||||
class _OpenResult:
|
||||
returncode = 0
|
||||
stdout = ""
|
||||
|
||||
def mock_run(*args, **kwargs):
|
||||
"""Mock subprocess.run with two different behaviors per call."""
|
||||
call_count[0] += 1
|
||||
# First call: osascript to choose application
|
||||
if call_count[0] == 1:
|
||||
return _AppChooseResult()
|
||||
# Second call: open command to open the file
|
||||
elif call_count[0] == 2:
|
||||
return _OpenResult()
|
||||
else:
|
||||
raise AssertionError(f"Unexpected call #{call_count[0]} to subprocess.run")
|
||||
|
||||
|
||||
with patch("webdrop_bridge.ui.main_window.sys.platform", "darwin"):
|
||||
with patch("webdrop_bridge.ui.main_window.subprocess.run", return_value=_Result()):
|
||||
with patch("webdrop_bridge.ui.main_window.subprocess.run", side_effect=mock_run):
|
||||
assert window._open_with_app_chooser(str(test_file)) is True
|
||||
|
||||
def test_open_with_app_chooser_unsupported_platform(self, qtbot, sample_config):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue