Skip to content

Commit 3a2d49e

Browse files
committed
Update tests with new package name
1 parent 4f630c4 commit 3a2d49e

9 files changed

+53
-26
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
include = pre_commit_hooks/*
2+
include = pre_commit_macadmin_hooks/*
33

44
[report]
55
exclude_lines =

tests/test_check_jamf_extension_attributes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_argument_parser(self):
2020
self.assertEqual(args.valid_shebangs, ["#!/bin/bash"])
2121

2222
@mock.patch(
23-
"pre_commit_hooks.check_jamf_extension_attributes.validate_shebangs",
23+
"pre_commit_macadmin_hooks.check_jamf_extension_attributes.validate_shebangs",
2424
return_value=True,
2525
)
2626
def test_valid_file(self, mock_validate):
@@ -32,7 +32,7 @@ def test_valid_file(self, mock_validate):
3232
self.assertEqual(retval, 0)
3333

3434
@mock.patch(
35-
"pre_commit_hooks.check_jamf_extension_attributes.validate_shebangs",
35+
"pre_commit_macadmin_hooks.check_jamf_extension_attributes.validate_shebangs",
3636
return_value=True,
3737
)
3838
def test_missing_result_tags(self, mock_validate):
@@ -46,7 +46,7 @@ def test_missing_result_tags(self, mock_validate):
4646
mock_print.assert_any_call(f"{tf.name}: missing <result> and/or </result> tags")
4747

4848
@mock.patch(
49-
"pre_commit_hooks.check_jamf_extension_attributes.validate_shebangs",
49+
"pre_commit_macadmin_hooks.check_jamf_extension_attributes.validate_shebangs",
5050
return_value=False,
5151
)
5252
def test_invalid_shebang(self, mock_validate):
@@ -60,7 +60,7 @@ def test_invalid_shebang(self, mock_validate):
6060
mock_print.assert_any_call(f"{tf.name}: does not start with a valid shebang")
6161

6262
@mock.patch(
63-
"pre_commit_hooks.check_jamf_extension_attributes.validate_shebangs",
63+
"pre_commit_macadmin_hooks.check_jamf_extension_attributes.validate_shebangs",
6464
return_value=True,
6565
)
6666
def test_multiple_files_mixed_results(self, mock_validate):
@@ -81,7 +81,7 @@ def test_multiple_files_mixed_results(self, mock_validate):
8181
)
8282

8383
@mock.patch(
84-
"pre_commit_hooks.check_jamf_extension_attributes.validate_shebangs",
84+
"pre_commit_macadmin_hooks.check_jamf_extension_attributes.validate_shebangs",
8585
return_value=True,
8686
)
8787
def test_no_filenames(self, mock_validate):

tests/test_check_jamf_scripts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class TestCheckJamfScripts(unittest.TestCase):
1010
def setUp(self):
1111
# Patch validate_shebangs for controlled behavior
1212
patcher = mock.patch(
13-
"pre_commit_hooks.check_jamf_scripts.validate_shebangs", return_value=True
13+
"pre_commit_macadmin_hooks.check_jamf_scripts.validate_shebangs",
14+
return_value=True,
1415
)
1516
self.mock_validate = patcher.start()
1617
self.addCleanup(patcher.stop)

tests/test_check_munki_pkgsinfo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setUp(self):
2222
]
2323
self.patchers = []
2424
for func in patcher_list:
25-
p = mock.patch(f"pre_commit_hooks.util.{func}", return_value=True)
25+
p = mock.patch(f"pre_commit_macadmin_hooks.util.{func}", return_value=True)
2626
self.patchers.append(p)
2727
p.start()
2828
self.addCleanup(lambda: [p.stop() for p in self.patchers])
@@ -72,7 +72,7 @@ def test_valid_pkginfo_returns_zero(self):
7272
# def test_missing_required_key_returns_one(self):
7373
# # Patch validate_required_keys to return False
7474
# with mock.patch(
75-
# "pre_commit_hooks.util.validate_required_keys", return_value=False
75+
# "pre_commit_macadmin_hooks.util.validate_required_keys", return_value=False
7676
# ):
7777
# pkginfo = {
7878
# "name": "foo",
@@ -264,7 +264,9 @@ def test_require_pkg_blocking_apps_missing_returns_one(self):
264264

265265
def test_script_with_invalid_shebang_returns_one(self):
266266
# Patch validate_shebangs to return False
267-
with mock.patch("pre_commit_hooks.util.validate_shebangs", return_value=False):
267+
with mock.patch(
268+
"pre_commit_macadmin_hooks.util.validate_shebangs", return_value=False
269+
):
268270
pkginfo = {
269271
"description": "desc",
270272
"name": "foo",

tests/test_check_munkiadmin_scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestCheckMunkiadminScripts(unittest.TestCase):
1010
def setUp(self):
1111
# Patch validate_shebangs for all tests
1212
patcher = mock.patch(
13-
"pre_commit_hooks.check_munkiadmin_scripts.validate_shebangs",
13+
"pre_commit_macadmin_hooks.check_munkiadmin_scripts.validate_shebangs",
1414
return_value=True,
1515
)
1616
self.mock_validate_shebangs = patcher.start()

tests/test_check_outset_scripts.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def test_build_argument_parser(self):
1515
self.assertEqual(args.filenames, ["file1", "file2"])
1616

1717
@mock.patch(
18-
"pre_commit_hooks.check_outset_scripts.validate_shebangs", return_value=True
18+
"pre_commit_macadmin_hooks.check_outset_scripts.validate_shebangs",
19+
return_value=True,
1920
)
2021
def test_main_executable_and_valid_shebang(self, mock_validate):
2122
with tempfile.NamedTemporaryFile(delete=False) as tf:
@@ -33,7 +34,8 @@ def test_main_executable_and_valid_shebang(self, mock_validate):
3334
os.unlink(filename)
3435

3536
@mock.patch(
36-
"pre_commit_hooks.check_outset_scripts.validate_shebangs", return_value=False
37+
"pre_commit_macadmin_hooks.check_outset_scripts.validate_shebangs",
38+
return_value=False,
3739
)
3840
def test_main_invalid_shebang(self, mock_validate):
3941
with tempfile.NamedTemporaryFile(delete=False) as tf:
@@ -53,7 +55,8 @@ def test_main_invalid_shebang(self, mock_validate):
5355
os.unlink(filename)
5456

5557
@mock.patch(
56-
"pre_commit_hooks.check_outset_scripts.validate_shebangs", return_value=True
58+
"pre_commit_macadmin_hooks.check_outset_scripts.validate_shebangs",
59+
return_value=True,
5760
)
5861
def test_main_not_executable(self, mock_validate):
5962
with tempfile.NamedTemporaryFile(delete=False) as tf:
@@ -72,7 +75,8 @@ def test_main_not_executable(self, mock_validate):
7275
os.unlink(filename)
7376

7477
@mock.patch(
75-
"pre_commit_hooks.check_outset_scripts.validate_shebangs", return_value=False
78+
"pre_commit_macadmin_hooks.check_outset_scripts.validate_shebangs",
79+
return_value=False,
7680
)
7781
def test_main_not_executable_and_invalid_shebang(self, mock_validate):
7882
with tempfile.NamedTemporaryFile(delete=False) as tf:

tests/test_forbid_autopkg_overrides.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def test_build_argument_parser_help_message(self):
2525
self.assertIn("Filenames to check.", help_text)
2626
self.assertIn("usage:", help_text)
2727

28-
@mock.patch("pre_commit_hooks.forbid_autopkg_overrides.load_autopkg_recipe")
28+
@mock.patch(
29+
"pre_commit_macadmin_hooks.forbid_autopkg_overrides.load_autopkg_recipe"
30+
)
2931
def test_main_recipe_missing_required_key(self, mock_load):
3032
# Simulate a recipe missing the "Process" key
3133
mock_load.return_value = {"Input": "value"}
@@ -37,7 +39,9 @@ def test_main_recipe_missing_required_key(self, mock_load):
3739
finally:
3840
os.unlink(filename)
3941

40-
@mock.patch("pre_commit_hooks.forbid_autopkg_overrides.load_autopkg_recipe")
42+
@mock.patch(
43+
"pre_commit_macadmin_hooks.forbid_autopkg_overrides.load_autopkg_recipe"
44+
)
4145
def test_main_recipe_with_required_key(self, mock_load):
4246
# Simulate a recipe with the "Process" key
4347
mock_load.return_value = {"Process": [], "Input": "value"}
@@ -49,7 +53,9 @@ def test_main_recipe_with_required_key(self, mock_load):
4953
finally:
5054
os.unlink(filename)
5155

52-
@mock.patch("pre_commit_hooks.forbid_autopkg_overrides.load_autopkg_recipe")
56+
@mock.patch(
57+
"pre_commit_macadmin_hooks.forbid_autopkg_overrides.load_autopkg_recipe"
58+
)
5359
def test_main_recipe_load_returns_none(self, mock_load):
5460
# Simulate load_autopkg_recipe returning None (invalid file)
5561
mock_load.return_value = None
@@ -66,7 +72,9 @@ def test_build_argument_parser(self):
6672
args = parser.parse_args(["file1", "file2"])
6773
self.assertEqual(args.filenames, ["file1", "file2"])
6874

69-
@mock.patch("pre_commit_hooks.forbid_autopkg_overrides.load_autopkg_recipe")
75+
@mock.patch(
76+
"pre_commit_macadmin_hooks.forbid_autopkg_overrides.load_autopkg_recipe"
77+
)
7078
def test_main_multiple_files(self, mock_load):
7179
# First file is valid, second is missing required key
7280
mock_load.side_effect = [{"Process": []}, {"Input": "value"}]
@@ -81,7 +89,9 @@ def test_main_multiple_files(self, mock_load):
8189
os.unlink(filenames[0])
8290
os.unlink(filenames[1])
8391

84-
@mock.patch("pre_commit_hooks.forbid_autopkg_overrides.load_autopkg_recipe")
92+
@mock.patch(
93+
"pre_commit_macadmin_hooks.forbid_autopkg_overrides.load_autopkg_recipe"
94+
)
8595
def test_main_no_filenames(self, mock_load):
8696
# No files to check, should return 0
8797
result = target.main([])

tests/test_forbid_autopkg_trust_info.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ def test_build_argument_parser(self):
1010
args = parser.parse_args(["file1", "file2"])
1111
self.assertEqual(args.filenames, ["file1", "file2"])
1212

13-
@mock.patch("pre_commit_hooks.forbid_autopkg_trust_info.load_autopkg_recipe")
13+
@mock.patch(
14+
"pre_commit_macadmin_hooks.forbid_autopkg_trust_info.load_autopkg_recipe"
15+
)
1416
def test_main_no_files(self, mock_load):
1517
# No files provided, should return 0
1618
ret = target.main([])
1719
self.assertEqual(ret, 0)
1820
mock_load.assert_not_called()
1921

20-
@mock.patch("pre_commit_hooks.forbid_autopkg_trust_info.load_autopkg_recipe")
22+
@mock.patch(
23+
"pre_commit_macadmin_hooks.forbid_autopkg_trust_info.load_autopkg_recipe"
24+
)
2125
def test_main_file_with_no_recipe(self, mock_load):
2226
mock_load.return_value = None
2327
ret = target.main(["fakefile"])
2428
self.assertEqual(ret, 1)
2529
mock_load.assert_called_once_with("fakefile")
2630

27-
@mock.patch("pre_commit_hooks.forbid_autopkg_trust_info.load_autopkg_recipe")
31+
@mock.patch(
32+
"pre_commit_macadmin_hooks.forbid_autopkg_trust_info.load_autopkg_recipe"
33+
)
2834
def test_main_file_with_trust_info(self, mock_load):
2935
mock_load.return_value = {"ParentRecipeTrustInfo": {}}
3036
with mock.patch("builtins.print") as mock_print:
@@ -34,13 +40,17 @@ def test_main_file_with_trust_info(self, mock_load):
3440
"recipe_with_trust: trust info in recipe"
3541
)
3642

37-
@mock.patch("pre_commit_hooks.forbid_autopkg_trust_info.load_autopkg_recipe")
43+
@mock.patch(
44+
"pre_commit_macadmin_hooks.forbid_autopkg_trust_info.load_autopkg_recipe"
45+
)
3846
def test_main_file_without_trust_info(self, mock_load):
3947
mock_load.return_value = {"Input": {}}
4048
ret = target.main(["recipe_without_trust"])
4149
self.assertEqual(ret, 0)
4250

43-
@mock.patch("pre_commit_hooks.forbid_autopkg_trust_info.load_autopkg_recipe")
51+
@mock.patch(
52+
"pre_commit_macadmin_hooks.forbid_autopkg_trust_info.load_autopkg_recipe"
53+
)
4454
def test_main_multiple_files(self, mock_load):
4555
# First file: valid, second: missing, third: has trust info
4656
mock_load.side_effect = [{"Input": {}}, None, {"ParentRecipeTrustInfo": {}}]

tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""test_util.py
22
3-
Unit tests for the shared/utility functions in pre_commit_hooks.util module.
3+
Unit tests for the shared/utility functions in pre_commit_macadmin_hooks.util module.
44
"""
55

66
import json

0 commit comments

Comments
 (0)