File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ def create_and_upload_card(args):
356356 )
357357
358358 updated_card = _update_kernel_card_usage (
359- kernel_card = kernel_card , local_path = kernel_dir
359+ kernel_card = kernel_card , local_path = kernel_dir , repo_id = args . repo_id
360360 )
361361 updated_card = _update_kernel_card_available_funcs (
362362 kernel_card = kernel_card , local_path = kernel_dir
Original file line number Diff line number Diff line change 11import tempfile
22from pathlib import Path
33from dataclasses import dataclass
4+ from unittest .mock import patch
45
56import pytest
67
@@ -273,3 +274,23 @@ def test_create_and_upload_card_custom_description(mock_kernel_dir):
273274 card_content = card_path .read_text ()
274275
275276 assert custom_desc in card_content
277+
278+
279+ def test_create_and_upload_card_usage_with_repo_id (mock_kernel_dir ):
280+ """Test that usage code snippet includes the provided repo_id."""
281+ with tempfile .TemporaryDirectory () as tmpdir :
282+ card_path = Path (tmpdir ) / "README.md"
283+
284+ args = CardArgs (
285+ kernel_dir = str (mock_kernel_dir ),
286+ card_path = str (card_path ),
287+ repo_id = "my-org/my-kernel" ,
288+ )
289+
290+ with patch ("huggingface_hub.ModelCard.push_to_hub" ):
291+ create_and_upload_card (args )
292+
293+ card_content = card_path .read_text ()
294+
295+ assert "## How to use" in card_content
296+ assert 'get_kernel("my-org/my-kernel")' in card_content
You can’t perform that action at this time.
0 commit comments