Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/autopkg/autopkg into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcspadden committed Sep 21, 2023
2 parents ee66036 + 0fd6d86 commit bd8ef7b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
4 changes: 1 addition & 3 deletions Code/autopkg
Original file line number Diff line number Diff line change
Expand Up @@ -1307,9 +1307,7 @@ def find_processor_path(processor_name, recipe, env=None):
processor_recipe_id,
) = extract_processor_name_with_recipe_identifier(processor_name)
if processor_recipe_id:
shared_processor_recipe_path = find_recipe_by_id_in_map(
processor_recipe_id
)
shared_processor_recipe_path = find_recipe_by_id_in_map(processor_recipe_id)
if shared_processor_recipe_path:
processor_search_dirs.append(
os.path.dirname(shared_processor_recipe_path)
Expand Down
8 changes: 4 additions & 4 deletions Code/autopkglib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ def find_recipe_by_id_in_map(
return None


def find_recipe_by_name_in_map(name: str, skip_overrides: bool = False) -> Optional[str]:
def find_recipe_by_name_in_map(
name: str, skip_overrides: bool = False
) -> Optional[str]:
"""Search recipe map for a shortname"""
# Check the overrides first, unless skipping them
if not skip_overrides and name in globalRecipeMap["overrides"]:
Expand Down Expand Up @@ -1066,9 +1068,7 @@ def get_processor(processor_name, verbose=None, recipe=None, env=None):
processor_recipe_id,
) = extract_processor_name_with_recipe_identifier(processor_name)
if processor_recipe_id:
shared_processor_recipe_path = find_recipe_by_id_in_map(
processor_recipe_id
)
shared_processor_recipe_path = find_recipe_by_id_in_map(processor_recipe_id)
if shared_processor_recipe_path:
processor_search_dirs.append(
os.path.dirname(shared_processor_recipe_path)
Expand Down
40 changes: 31 additions & 9 deletions Code/tests/test_autopkglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def setUp(self):
# This forces autopkglib to accept our patching of memoize
imp.reload(autopkglib)
autopkglib.globalPreferences
self.mock_recipemap = patch.object(autopkglib, "globalRecipeMap", self.recipe_file_struct)
self.mock_recipemap = patch.object(
autopkglib, "globalRecipeMap", self.recipe_file_struct
)

def tearDown(self):
pass
Expand Down Expand Up @@ -245,16 +247,26 @@ def test_find_recipe_by_name_in_map_override(self, mock_valid):
"""find_recipe_by_name_in_map should return identifier from overrides in map"""
mock_valid.return_value = True
with self.mock_recipemap:
id = autopkglib.find_recipe_by_name_in_map("GoogleChrome.download", skip_overrides=False)
self.assertEqual(id, '/Users/test/Library/AutoPkg/RecipeOverrides/GoogleChrome.download.recipe')
id = autopkglib.find_recipe_by_name_in_map(
"GoogleChrome.download", skip_overrides=False
)
self.assertEqual(
id,
"/Users/test/Library/AutoPkg/RecipeOverrides/GoogleChrome.download.recipe",
)

@patch("autopkglib.valid_recipe_file")
def test_find_recipe_by_name_in_map_no_override(self, mock_valid):
"""find_recipe_by_name_in_map should return identifier from recipe repos in map."""
mock_valid.return_value = True
with self.mock_recipemap:
id = autopkglib.find_recipe_by_name_in_map("GoogleChrome.download", skip_overrides=True)
self.assertEqual(id, "/Users/test/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/GoogleChrome/GoogleChrome.download.recipe")
id = autopkglib.find_recipe_by_name_in_map(
"GoogleChrome.download", skip_overrides=True
)
self.assertEqual(
id,
"/Users/test/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/GoogleChrome/GoogleChrome.download.recipe",
)

@patch("autopkglib.valid_recipe_file")
def test_find_recipe_by_name_in_map_returns_none_if_missing(self, mock_valid):
Expand All @@ -271,16 +283,26 @@ def test_find_recipe_by_id_in_map_override(self, mock_valid):
"""find_recipe_by_id_in_map should return identifier from overrides in map."""
mock_valid.return_value = True
with self.mock_recipemap:
id = autopkglib.find_recipe_by_id_in_map("local.download.GoogleChrome", skip_overrides=False)
self.assertEqual(id, '/Users/test/Library/AutoPkg/RecipeOverrides/GoogleChrome.download.recipe')
id = autopkglib.find_recipe_by_id_in_map(
"local.download.GoogleChrome", skip_overrides=False
)
self.assertEqual(
id,
"/Users/test/Library/AutoPkg/RecipeOverrides/GoogleChrome.download.recipe",
)

@patch("autopkglib.valid_recipe_file")
def test_find_recipe_by_id_in_map_no_override(self, mock_valid):
"""find_recipe_by_id_in_map should return identifier from recipe repos in map."""
mock_valid.return_value = True
with self.mock_recipemap:
id = autopkglib.find_recipe_by_id_in_map("com.github.autopkg.download.googlechrome", skip_overrides=True)
self.assertEqual(id, "/Users/test/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/GoogleChrome/GoogleChrome.download.recipe")
id = autopkglib.find_recipe_by_id_in_map(
"com.github.autopkg.download.googlechrome", skip_overrides=True
)
self.assertEqual(
id,
"/Users/test/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/GoogleChrome/GoogleChrome.download.recipe",
)

@patch("autopkglib.valid_recipe_file")
def test_find_recipe_by_id_in_map_returns_none_if_missing(self, mock_valid):
Expand Down

0 comments on commit bd8ef7b

Please sign in to comment.