def test_run_image(self, mock_datetime: Mock, open: Mock, _load_group_config: Mock, _get_image_distgit_branch: Mock, _build_plashets: Mock, _rebase_image: Mock, _generate_repo_file_for_image: Mock, _copy_plashet_out_to_remote: Mock, _build_image: Mock, _generate_example_schema: Mock): mock_datetime.utcnow.return_value = datetime(2021, 7, 16, 0, 0, 0, 0, tzinfo=timezone.utc) timestamp = mock_datetime.utcnow.return_value.strftime("%Y%m%d%H%M") runtime = MagicMock(dry_run=False) pipeline = RebuildPipeline(runtime, group="openshift-4.9", assembly="art0001", type=RebuildType.IMAGE, dg_key="foo") group_config = { "arches": ["x86_64", "s390x"], "signing_advisory": 12345, } _load_group_config.return_value = group_config _get_image_distgit_branch.return_value = "rhaos-4.9-rhel-8" _build_plashets.return_value = (Path("/path/to/plashet-a"), "http://example.com/plashet-a", Path("/path/to/plashet-b"), "http://example.com/plashet-b") _build_image.return_value = ["foo-container-v1.2.3-1"] _generate_example_schema.return_value = {"some_key": "some_value"} get_event_loop().run_until_complete(pipeline.run()) _load_group_config.assert_called_once_with() _get_image_distgit_branch.assert_called_once_with(group_config) _build_plashets.assert_called_once_with(timestamp, 8, group_config) _rebase_image.assert_called_once_with(f"{timestamp}.p?") open.assert_called_once_with(Path("/path/to/plashet-b/rebuild.repo"), "w") _generate_repo_file_for_image.assert_called_once_with( open.return_value.__enter__.return_value, "plashet-a", "http://example.com/plashet-b") _copy_plashet_out_to_remote.assert_any_call(8, Path("/path/to/plashet-a")) _copy_plashet_out_to_remote.assert_any_call(8, Path("/path/to/plashet-b")) _build_image.assert_called_once_with( "http://example.com/plashet-b/rebuild.repo") _generate_example_schema.assert_called_once_with( _build_image.return_value)
def test_run_rhcos(self, mock_datetime: Mock, open: Mock, _load_group_config: Mock, _build_plashets: Mock, _generate_repo_file_for_rhcos: Mock, _copy_plashet_out_to_remote: Mock): mock_datetime.utcnow.return_value = datetime(2021, 7, 16, 0, 0, 0, 0, tzinfo=timezone.utc) timestamp = mock_datetime.utcnow.return_value.strftime("%Y%m%d%H%M") runtime = MagicMock(dry_run=False) pipeline = RebuildPipeline(runtime, group="openshift-4.9", assembly="art0001", type=RebuildType.RHCOS, dg_key=None) group_config = { "arches": ["x86_64", "s390x"], "signing_advisory": 12345, } _load_group_config.return_value = group_config _build_plashets.return_value = (Path("/path/to/plashet-a"), "http://example.com/plashet-a", Path("/path/to/plashet-b"), "http://example.com/plashet-b") get_event_loop().run_until_complete(pipeline.run()) _load_group_config.assert_called_once_with() _build_plashets.assert_called_once_with(timestamp, 8, group_config) open.assert_called_once_with(Path("/path/to/plashet-b/rebuild.repo"), "w") _generate_repo_file_for_rhcos.assert_called_once_with( open.return_value.__enter__.return_value, "http://example.com/plashet-a", "http://example.com/plashet-b") _copy_plashet_out_to_remote.assert_any_call(8, Path("/path/to/plashet-a")) _copy_plashet_out_to_remote.assert_any_call(8, Path("/path/to/plashet-b"))
def test_run_rpm(self, mock_datetime: Mock, _rebase_and_build_rpm: Mock, _generate_example_schema: Mock): mock_datetime.utcnow.return_value = datetime(2021, 7, 16, 0, 0, 0, 0, tzinfo=timezone.utc) runtime = MagicMock(dry_run=False) pipeline = RebuildPipeline(runtime, group="openshift-4.9", assembly="art0001", type=RebuildType.RPM, dg_key="foo") _rebase_and_build_rpm.return_value = [ "foo-v1.2.3-1.el8", "foo-v1.2.3-1.el7" ] _generate_example_schema.return_value = {"some_key": "some_value"} get_event_loop().run_until_complete(pipeline.run()) _rebase_and_build_rpm.assert_called_once_with("202107160000.p?") _generate_example_schema.assert_called_once_with( _rebase_and_build_rpm.return_value)