|
13 | 13 | @pytest.mark.skipif( |
14 | 14 | # Added to the v2023.05.0 milestone |
15 | 15 | # https://github.com/rstudio/connect/pull/23148 |
16 | | - CONNECT_VERSION < version.parse("2023.05.0"), |
| 16 | + CONNECT_VERSION < version.parse("2024.05.0"), |
17 | 17 | reason="Cache runtimes not implemented", |
18 | 18 | ) |
19 | 19 | class TestSystem: |
20 | 20 | @classmethod |
21 | 21 | def setup_class(cls): |
22 | 22 | cls.client = Client() |
23 | | - assert cls.client.content.count() == 0 |
24 | | - cls.content_item = cls.client.content.create(name="Content_A") |
25 | | - |
26 | | - # Copied from from integration/tests/posit/connect/test_packages.py |
27 | | - def _deploy_python_bundle(self): |
| 23 | + cls.content = cls.client.content.create(name=cls.__name__) |
28 | 24 | path = Path("../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz") |
29 | 25 | path = (Path(__file__).parent / path).resolve() |
30 | | - bundle = self.content_item.bundles.create(str(path)) |
| 26 | + bundle = cls.content.bundles.create(str(path)) |
31 | 27 | task = bundle.deploy() |
32 | 28 | task.wait_for() |
33 | 29 |
|
34 | | - def _remove_all_caches(self): |
35 | | - caches: list[SystemRuntimeCache] = self.client.system.caches.runtime.find() |
36 | | - for cache in caches: |
37 | | - assert isinstance(cache, SystemRuntimeCache) |
38 | | - none_val = cache.destroy(dry_run=True) |
39 | | - assert none_val is None |
40 | | - task: Task = cache.destroy() |
41 | | - assert isinstance(task, Task) |
42 | | - task.wait_for() |
43 | | - assert len(self.client.system.caches.runtime.find()) == 0 |
44 | | - |
45 | 30 | @classmethod |
46 | 31 | def teardown_class(cls): |
47 | | - cls.content_item.delete() |
48 | | - assert cls.client.content.count() == 0 |
| 32 | + cls.content.delete() |
49 | 33 |
|
50 | 34 | def test_runtime_caches(self): |
51 | | - # Get current caches |
52 | | - caches: list[SystemRuntimeCache] = self.client.system.caches.runtime.find() |
53 | | - assert isinstance(caches, list) |
54 | | - |
55 | | - # Remove all caches |
56 | | - self._remove_all_caches() |
57 | | - |
58 | | - # Deploy a new cache |
59 | | - self._deploy_python_bundle() |
60 | | - |
61 | | - # Check if the cache is deployed |
62 | 35 | caches = self.client.system.caches.runtime.find() |
63 | | - |
64 | | - # Barret 2024/12: |
65 | | - # Caches only showing up in Connect versions >= 2024.05.0 |
66 | | - # I do not know why. |
67 | | - # Since we are not logic testing Connect, we can confirm our code works given more recent versions of Connect. |
68 | | - if CONNECT_VERSION >= version.parse("2024.05.0"): |
69 | | - assert len(caches) > 0 |
70 | | - |
71 | | - # Remove all caches |
72 | | - self._remove_all_caches() |
| 36 | + assert len(caches) > 0 |
0 commit comments