Debian Codegraph @

tests/integrations/subprocess/test_NativeAppContext__verify.py

raw
1 import pytest
2
3 from briefcase.exceptions import UnsupportedHostError
4 from briefcase.integrations.subprocess import NativeAppContext, Subprocess
5
6
7 def test_short_circuit(mock_tools, first_app_config):
8 """Tool is not created if already cached."""
9 mock_tools[first_app_config].app_context = "tool"
10
11 tool = NativeAppContext.verify(mock_tools, first_app_config)
12
13 assert tool == "tool"
14 assert tool == mock_tools[first_app_config].app_context
15
16
17 def test_unsupported_os(mock_tools):
18 """When host OS is not supported, an error is raised."""
19 mock_tools.host_os = "wonky"
20
21 with pytest.raises(
22 UnsupportedHostError,
23 match=f"{NativeAppContext.name} is not supported on wonky",
24 ):
25 NativeAppContext.verify(mock_tools, app=object())
26
27
28 def test_verify(mock_tools, first_app_config):
29 """Subprocess verify always returns/sets subprocess tool."""
30 native_app_context_tool = NativeAppContext.verify(mock_tools, first_app_config)
31
32 assert isinstance(native_app_context_tool, Subprocess)
33 assert native_app_context_tool is mock_tools[first_app_config].app_context
34 # native app context should be the default subprocess tool
35 assert native_app_context_tool is mock_tools.subprocess