Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: mock file age in python units #211

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion manager/tests/unit/cli/test_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from click.testing import CliRunner
from moto import mock_s3
from unittest.mock import patch

from grype_db_manager import cli, utils
from grype_db_manager import db
Expand Down Expand Up @@ -129,10 +130,14 @@ def create_tar_gz(built: str, version: int):
],
)
@mock_s3
def test_create_listing(test_dir_path, listing_s3_mock, case_dir, expected_exit_code, extra_dbs: list[str], contains):
@patch("grype_db_manager.distribution.age_from_basename")
def test_create_listing(
mock_file_age, test_dir_path, listing_s3_mock, case_dir, expected_exit_code, extra_dbs: list[str], contains
):
# contains an application config file
config_dir_path = test_dir_path(f"fixtures/listing/{case_dir}")
listing_s3_mock(config_dir_path, extra_dbs=extra_dbs)
mock_file_age.return_value = 42 # needs to be less than distribution.MAX_DB_AGE

with utils.set_directory(config_dir_path):
with open("expected-listing.json") as f:
Expand Down