@@ -82,42 +82,20 @@ def test_imagetools_create_annotations_type_validation():
8282 assert "must be a dict" in str (err .value )
8383
8484
85- @patch ("python_on_whales.components.buildx.imagetools.cli_wrapper.run" )
86- def test_imagetools_create_with_annotations_command_construction (mock_run ):
87- """Test that annotations are properly passed to the Docker CLI command"""
88- mock_run .return_value = '{"mediaType": "application/vnd.docker.distribution.manifest.v2+json", "schemaVersion": 2}'
89-
85+ def test_imagetools_create_with_annotations_command_construction ():
9086 annotations = {
91- "org.opencontainers.image.source" : "https://github.com/user/repo" ,
92- "org.opencontainers.image.description" : "Test image" ,
87+ "index: org.opencontainers.image.source" : "https://github.com/user/repo" ,
88+ "index: org.opencontainers.image.description" : "Test image" ,
9389 }
9490
95- docker .buildx .imagetools .create (
91+ manifest = docker .buildx .imagetools .create (
9692 sources = ["python:3.13.0" ],
9793 tags = ["myrepo/myimage:latest" ],
9894 annotations = annotations ,
9995 dry_run = True ,
10096 )
10197
102- # Verify the command was called
103- assert mock_run . called
104- called_command = mock_run . call_args [ 0 ][ 0 ]
98+ assert len ( manifest . annotations ) == 2
99+ assert manifest . annotations [ "org.opencontainers.image.source" ] == "https://github.com/user/repo"
100+ assert manifest . annotations [ "org.opencontainers.image.description" ] == "Test image"
105101
106- # Check that the command contains the annotations
107- assert "--annotation" in called_command
108- assert (
109- "org.opencontainers.image.source=https://github.com/user/repo" in called_command
110- )
111- assert "org.opencontainers.image.description=Test image" in called_command
112-
113- # Verify both annotations are present
114- annotation_indices = [
115- i for i , x in enumerate (called_command ) if x == "--annotation"
116- ]
117- assert len (annotation_indices ) == 2
118-
119- # Check other expected flags and arguments are present
120- assert "--dry-run" in called_command
121- assert "--tag" in called_command
122- assert "myrepo/myimage:latest" in called_command
123- assert "python:3.13.0" in called_command
0 commit comments