mirror of
https://github.com/modelscope/modelscope.git
synced 2026-08-29 10:08:40 +02:00
add download first for scan cache test
This commit is contained in:
@@ -9,9 +9,13 @@ from modelscope.utils.file_utils import get_modelscope_cache_dir
|
||||
class TestScanCacheCommand(unittest.TestCase):
|
||||
"""Test cases for scancache command in ModelScope CLI."""
|
||||
|
||||
def setUp(self):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Set up for tests."""
|
||||
self.fake_cache_dir = '/fake/cache/path'
|
||||
# download one file to ensure the cache directory exists
|
||||
model_id = 'Qwen/Qwen3-0.6B'
|
||||
cmd = f'python -m modelscope.cli.cli download --model {model_id} README.md'
|
||||
subprocess.getstatusoutput(cmd)
|
||||
|
||||
def test_scan_default_dir(self):
|
||||
cmd = 'python -m modelscope.cli.cli scan-cache'
|
||||
@@ -26,7 +30,7 @@ class TestScanCacheCommand(unittest.TestCase):
|
||||
self.assertIn('Done', output)
|
||||
|
||||
def test_scan_not_exist_dir(self):
|
||||
cmd = f'python -m modelscope.cli.cli scan-cache --dir {self.fake_cache_dir}'
|
||||
cmd = 'python -m modelscope.cli.cli scan-cache --dir /fake/cache/path'
|
||||
stat, output = subprocess.getstatusoutput(cmd)
|
||||
self.assertEqual(stat, 0)
|
||||
self.assertIn('not found', output)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Copyright (c) Alibaba, Inc. and its affiliates.
|
||||
import unittest
|
||||
|
||||
from modelscope import snapshot_download
|
||||
from modelscope.hub.cache_manager import scan_cache_dir
|
||||
from modelscope.hub.errors import CacheNotFound
|
||||
from modelscope.utils.file_utils import get_modelscope_cache_dir
|
||||
@@ -11,9 +12,12 @@ logger = get_logger()
|
||||
|
||||
class HubScanCacheTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Set up for tests."""
|
||||
self.fake_cache_dir = '/fake/cache/path'
|
||||
# download one file to ensure the cache directory exists
|
||||
model_id = 'Qwen/Qwen3-0.6B'
|
||||
snapshot_download(model_id, allow_file_pattern='README.md')
|
||||
|
||||
def test_scan_default_dir(self):
|
||||
"""Test scanning the default cache directory."""
|
||||
|
||||
Reference in New Issue
Block a user