From e2287024392ddcfa94d2ab3a71042f6d9fcbc314 Mon Sep 17 00:00:00 2001 From: ckunki Date: Thu, 14 Mar 2024 11:08:12 +0100 Subject: [PATCH] Fixed some review findings --- test/unit/entrypoint/test_file_permissions.py | 5 ++--- test/unit/entrypoint/test_user_class.py | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/unit/entrypoint/test_file_permissions.py b/test/unit/entrypoint/test_file_permissions.py index 23d3819b..a86899cf 100644 --- a/test/unit/entrypoint/test_file_permissions.py +++ b/test/unit/entrypoint/test_file_permissions.py @@ -30,11 +30,10 @@ def test_file_inspector_group_accessible(accessible_file): assert testee.is_group_accessible() -def test_file_inspector_not_group_accessible(non_accessible_file): +def test_file_inspector_insufficient_group_permissions(non_accessible_file): testee = entrypoint.FileInspector(non_accessible_file) - with pytest.raises(PermissionError) as err: + with pytest.raises(PermissionError, match="No rw permissions for group") as err: testee.is_group_accessible() - assert re.match(r"No rw permissions for group", str(err.value)) def test_group_access_enable_existing_group(mocker, capsys): diff --git a/test/unit/entrypoint/test_user_class.py b/test/unit/entrypoint/test_user_class.py index 240a7153..609afbe4 100644 --- a/test/unit/entrypoint/test_user_class.py +++ b/test/unit/entrypoint/test_user_class.py @@ -49,10 +49,11 @@ def test_user_specified(user, group, docker, expected): def test_uid(mocker, user): - mocker.patch("pwd.getpwnam") - user.id - assert pwd.getpwnam.called - assert pwd.getpwnam.call_args == mocker.call("jennifer") + passwd_struct = MagicMock(pw_uid=444) + mocker.patch("pwd.getpwnam", return_value=passwd_struct) + assert 444 == user.id \ + and pwd.getpwnam.called \ + and pwd.getpwnam.call_args == mocker.call("jennifer") def test_enable_file_absent(mocker, user):