-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_image_info.py
43 lines (38 loc) · 1.22 KB
/
test_image_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from unittest import mock
import pytest
from buildrunner.docker.image_info import BuiltTaggedImage, BuiltImageInfo
@pytest.mark.parametrize(
"system_result, machine_result, platform_result",
[
("Darwin", "x86_64", "linux/amd64"),
("Darwin", "aarch64", "linux/arm64/v7"),
("Linux", "x86_64", "linux/amd64"),
("Linux", "aarch64", "linux/arm64/v7"),
("Bogus", "Noarch", "bogus"),
],
)
@mock.patch("buildrunner.docker.image_info.python_platform")
def test_find_native_platform(
platform_mock,
system_result,
machine_result,
platform_result,
):
platform_mock.system.return_value = system_result
platform_mock.machine.return_value = machine_result
run_id = "abc123"
built_image = BuiltImageInfo(id=run_id)
for platform in ("bogus", "linux/arm64/v7", "linux/amd64"):
built_image.add_platform_image(
platform,
BuiltTaggedImage(
repo="repo1",
tag=f'{run_id}-{platform.replace("/", "-")}',
digest="12345",
platform=platform,
),
)
assert (
built_image.native_platform_image
== built_image.images_by_platform[platform_result]
)