Skip to content

Commit

Permalink
Mock umasking from CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Jan 6, 2025
1 parent d53079f commit 6fa9b0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 0 additions & 8 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
import os


def current_umask() -> int:
# You can't get the current umask without changing it
tmp = os.umask(0o022)
os.umask(tmp)
return tmp
5 changes: 3 additions & 2 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from requests.exceptions import ConnectionError
from responses import matchers
from stomp.connect import StompConnection11 as Connection
from tests import current_umask

from blueapi import __version__
from blueapi.cli.cli import main
Expand Down Expand Up @@ -63,15 +62,17 @@ def test_main_no_params():

@patch("blueapi.service.main.start")
@patch("blueapi.cli.scratch.setup_scratch")
@patch("blueapi.cli.cli.os.umask")
@pytest.mark.parametrize("subcommand", ["serve", "setup-scratch"])
def test_runs_with_umask_002(
mock_umask: Mock,
mock_setup_scratch: Mock,
mock_start: Mock,
runner: CliRunner,
subcommand: str,
):
runner.invoke(main, [subcommand])
assert current_umask() == 0o002
mock_umask.assert_called_once_with(0o002)


@patch("requests.request")
Expand Down

0 comments on commit 6fa9b0e

Please sign in to comment.