From 3db118706c0f8b011b924c180ea32f5e8daae567 Mon Sep 17 00:00:00 2001 From: Janine Olear Date: Tue, 25 Jul 2023 10:00:50 +0200 Subject: [PATCH] add test for TransformerGoogleV2RHEL Signed-off-by: Janine Olear --- tests/transformer/test_google_rhel.py | 33 +++++++++++++++++++ .../a2f9b1c21e096445099c419aa0c0c9bc32657059 | 1 + 2 files changed, 34 insertions(+) create mode 100644 tests/transformer/test_google_rhel.py create mode 100644 tests/transformer/testdata/expected/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059 diff --git a/tests/transformer/test_google_rhel.py b/tests/transformer/test_google_rhel.py new file mode 100644 index 00000000..fdf4b4f5 --- /dev/null +++ b/tests/transformer/test_google_rhel.py @@ -0,0 +1,33 @@ +"""Tests for the v2 Google RHEL transformer.""" +import filecmp +import os + +from cloudimagedirectory import transformer + + +def test_aws_v2_rhel_transformer_command(runner, tmp_path): + """Verify that we can transform Google data for RHEL.""" + result = runner.invoke( + transformer.run, + [ + "-f", + "tests/transformer/testdata/input/raw/google/all.json", + "-op=.", + f"-dp={tmp_path}", + "--filter.until=none", + ], + ) + + assert result.exit_code == 0, f"expected no error, but got code {result.exit_code} and output:\n{result.output}" + + # Ensure the directory was made. + assert os.path.isdir(f"{tmp_path}/v2/os/rhel/provider/google/version/7/region/global/image") + + # Get current directory + pwd = os.getcwd() + + # Check image data by comparing the expected file and the output file byte by byte. + assert filecmp.cmp( + f"{pwd}/tests/transformer/testdata/expected/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059", + f"{tmp_path}/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059", + ) diff --git a/tests/transformer/testdata/expected/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059 b/tests/transformer/testdata/expected/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059 new file mode 100644 index 00000000..094e4897 --- /dev/null +++ b/tests/transformer/testdata/expected/v2/os/rhel/provider/google/version/7/region/global/image/a2f9b1c21e096445099c419aa0c0c9bc32657059 @@ -0,0 +1 @@ +{"name": "RHEL 7 X86_64", "arch": "X86_64", "version": "7", "imageId": "https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/images/rhel-7-v20230306", "date": "2023-03-06T12:57:17.210-08:00", "selflink": "https://console.cloud.google.com/compute/imagesDetail/projects/rhel-cloud/global/images/rhel-7-v20230306"}