|
9 | 9 |
|
10 | 10 |
|
11 | 11 | class TestDownloadCommand(unittest.TestCase): |
12 | | - """Test the download CLI command.""" |
| 12 | + @patch("cloudsmith_cli.core.download.list_packages") |
| 13 | + @patch("cloudsmith_cli.cli.commands.download.resolve_auth") |
| 14 | + def test_download_with_tag_filter_integration( |
| 15 | + self, mock_resolve_auth, mock_list_packages |
| 16 | + ): |
| 17 | + """Integration test: download command with --tag filter (end-to-end).""" |
| 18 | + mock_session = Mock() |
| 19 | + mock_resolve_auth.return_value = (mock_session, {}, "none") |
| 20 | + |
| 21 | + # Simulate two packages, only one matches the tag |
| 22 | + mock_packages = [ |
| 23 | + { |
| 24 | + "name": "test-package", |
| 25 | + "version": "1.0.0", |
| 26 | + "format": "deb", |
| 27 | + "tags": {"info": ["latest", "beta"]}, |
| 28 | + "filename": "test-package_1.0.0.deb", |
| 29 | + "cdn_url": "https://example.com/test-package_1.0.0.deb", |
| 30 | + "size": 1024, |
| 31 | + }, |
| 32 | + { |
| 33 | + "name": "test-package", |
| 34 | + "version": "0.9.0", |
| 35 | + "format": "deb", |
| 36 | + "tags": {"info": ["beta"]}, |
| 37 | + "filename": "test-package_0.9.0.deb", |
| 38 | + "cdn_url": "https://example.com/test-package_0.9.0.deb", |
| 39 | + "size": 512, |
| 40 | + }, |
| 41 | + ] |
| 42 | + mock_page_info = Mock() |
| 43 | + mock_page_info.is_valid = True |
| 44 | + mock_page_info.page = 1 |
| 45 | + mock_page_info.page_total = 1 |
| 46 | + mock_list_packages.return_value = (mock_packages, mock_page_info) |
| 47 | + |
| 48 | + runner = CliRunner() |
| 49 | + result = runner.invoke( |
| 50 | + download, |
| 51 | + [ |
| 52 | + "--config-file", |
| 53 | + "/dev/null", |
| 54 | + "testorg/testrepo", |
| 55 | + "test-package", |
| 56 | + "--tag", |
| 57 | + "latest", |
| 58 | + "--dry-run", |
| 59 | + ], |
| 60 | + ) |
| 61 | + |
| 62 | + self.assertEqual(result.exit_code, 0) |
| 63 | + self.assertIn("test-package v1.0.0", result.output) |
| 64 | + self.assertNotIn("test-package v0.9.0", result.output) |
13 | 65 |
|
14 | 66 | def setUp(self): |
15 | 67 | self.runner = CliRunner() |
|
0 commit comments