Skip to content

Commit

Permalink
Remove old script and fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-tianquaw committed Apr 10, 2024
1 parent 3abeccd commit 148c137
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 61 deletions.
31 changes: 0 additions & 31 deletions src/collect_pkg_metadata.py

This file was deleted.

41 changes: 11 additions & 30 deletions test/test_package_report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import absolute_import

import json

import pytest

pytestmark = pytest.mark.unit
Expand Down Expand Up @@ -36,25 +34,21 @@ def _create_env_out_docker_file(file_path):
)


def _create_base_image_package_metadata(file_path):
metadata = {
def _create_base_image_package_metadata():
return {
"libllvm18": {"version": "18.1.1", "size": 37301754},
"python": {"version": "3.12.1", "size": 30213651},
"tqdm": {"version": "4.66.2", "size": 89567},
}
with open(file_path, "w") as metadata_file:
json.dump(metadata, metadata_file)


def _create_target_image_package_metadata(file_path):
metadata = {
def _create_target_image_package_metadata():
return {
"libllvm18": {"version": "18.1.2", "size": 38407510},
"python": {"version": "3.12.2", "size": 32312631},
"libclang": {"version": "18.1.2", "size": 19272925},
"tqdm": {"version": "4.66.2", "size": 89567},
}
with open(file_path, "w") as metadata_file:
json.dump(metadata, metadata_file)


def test_get_match_specs(tmp_path):
Expand Down Expand Up @@ -121,18 +115,12 @@ def test_get_installed_package_versions_and_conda_versions(mock_run_command, tmp
assert latest_package_versions_in_conda_forge["numpy"] == "2.1.0"


def test_generate_package_size_report(capsys, tmp_path):
base_version_path = tmp_path / "base"
base_version_path.mkdir()
base_version_metadata_file = base_version_path / _image_generator_configs[1]["package_metadata_filename"]
_create_base_image_package_metadata(base_version_metadata_file)
target_version_path = tmp_path / "target"
target_version_path.mkdir()
target_version_metadata_file = target_version_path / _image_generator_configs[1]["package_metadata_filename"]
_create_target_image_package_metadata(target_version_metadata_file)
def test_generate_package_size_report(capsys):
base_pkg_metadata = _create_base_image_package_metadata()
target_pkg_metadata = _create_target_image_package_metadata()

_generate_python_package_size_report_per_image(
base_version_path, target_version_path, _image_generator_configs[1], "1.6.1", "1.6.2"
base_pkg_metadata, target_pkg_metadata, _image_generator_configs[1], "1.6.1", "1.6.2"
)

captured = capsys.readouterr()
Expand All @@ -152,18 +140,11 @@ def test_generate_package_size_report(capsys, tmp_path):
assert "tqdm|4.66.2|87.47KB" in captured.out


def test_generate_package_size_report_when_base_version_is_not_present(capsys, tmp_path):
base_version_path = tmp_path / "base"
base_version_path.mkdir()
base_version_metadata_file = base_version_path / _image_generator_configs[1]["package_metadata_filename"]
_create_base_image_package_metadata(base_version_metadata_file)
target_version_path = tmp_path / "target"
target_version_path.mkdir()
target_version_metadata_file = target_version_path / _image_generator_configs[1]["package_metadata_filename"]
_create_target_image_package_metadata(target_version_metadata_file)
def test_generate_package_size_report_when_base_version_is_not_present(capsys):
target_pkg_metadata = _create_target_image_package_metadata()

_generate_python_package_size_report_per_image(
None, target_version_path, _image_generator_configs[1], None, "1.6.2"
None, target_pkg_metadata, _image_generator_configs[1], None, "1.6.2"
)

captured = capsys.readouterr()
Expand Down

0 comments on commit 148c137

Please sign in to comment.