Skip to content

Commit

Permalink
Extract mock lock function from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Jan 28, 2025
1 parent e3c3dc0 commit f6f5ab3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions conda-store-server/tests/_internal/plugins/lock/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
from conda_store_server.plugins import plugin_context


def run_lock_side_effect(lockfile_path, **kwargs):
"""Mock method to simulate the output of running a
lock with conda-lock.
Dumps dummy data to the expected lockfile output location.
"""
with open(lockfile_path, "w") as f:
yaml.dump({"foo": "bar"}, f)


@pytest.mark.parametrize(
"specification",
[
Expand All @@ -30,11 +39,6 @@ def test_solve_lockfile(
):
"""Test that the call to conda_lock.run_lock is formed correctly."""

# Dump dummy data to the expected lockfile output location
def run_lock_side_effect(lockfile_path, **kwargs):
with open(lockfile_path, "w") as f:
yaml.dump({"foo": "bar"}, f)

mock_run_lock.side_effect = run_lock_side_effect

platforms = [conda_utils.conda_platform()]
Expand Down Expand Up @@ -81,11 +85,6 @@ def test_solve_right_conda_command(mock_run_lock, conda_store, simple_specificat
data={"conda_command": "conda"}
)

# Dump dummy data to the expected lockfile output location
def run_lock_side_effect(lockfile_path, **kwargs):
with open(lockfile_path, "w") as f:
yaml.dump({"foo": "bar"}, f)

mock_run_lock.side_effect = run_lock_side_effect

locker = conda_lock.CondaLock()
Expand Down

0 comments on commit f6f5ab3

Please sign in to comment.