|
4 | 4 | Optional, |
5 | 5 | ) |
6 | 6 |
|
7 | | -from galaxy_test.base.populators import ( |
8 | | - DatasetPopulator, |
9 | | - wait_on, |
10 | | -) |
| 7 | +from galaxy_test.base.populators import DatasetPopulator |
11 | 8 | from galaxy_test.driver import integration_util |
12 | 9 |
|
13 | 10 |
|
@@ -95,31 +92,30 @@ def test_purge_history_removes_underlying_datasets_from_disk(self): |
95 | 92 | # Purge the entire history |
96 | 93 | purge_response = self._delete(f"histories/{self.test_history_id}", data={"purge": True}, json=True) |
97 | 94 | self._assert_status_code_is_ok(purge_response) |
| 95 | + purge_result = purge_response.json() |
98 | 96 |
|
99 | 97 | # Verify history is purged |
100 | | - history_response = self._get(f"histories/{self.test_history_id}").json() |
101 | | - assert history_response["purged"] |
102 | | - assert history_response["deleted"] |
| 98 | + assert purge_result["purged"] |
| 99 | + assert purge_result["deleted"] |
| 100 | + |
| 101 | + # Verify the response contains a purge_task with an id |
| 102 | + assert "purge_task" in purge_result |
| 103 | + purge_task = purge_result["purge_task"] |
| 104 | + assert "id" in purge_task |
| 105 | + purge_task_id = purge_task["id"] |
| 106 | + |
| 107 | + # Wait for the celery task to complete via the tasks API |
| 108 | + self.dataset_populator.wait_on_task_id(purge_task_id) |
103 | 109 |
|
104 | | - # Verify HDAs are marked as purged |
| 110 | + # After task completion, HDAs should be purged and files deleted |
105 | 111 | self.dataset_populator.wait_for_purge(self.test_history_id, hda1_id) |
106 | 112 | self.dataset_populator.wait_for_purge(self.test_history_id, hda2_id) |
107 | | - |
108 | | - # Wait for underlying dataset files to be removed from disk. |
109 | | - # With batched history purging, HDAs are marked purged synchronously |
110 | | - # but the actual file deletion happens via a batched celery task. |
111 | | - self._wait_for_file_deleted(dataset_file1) |
112 | | - self._wait_for_file_deleted(dataset_file2) |
| 113 | + assert not self._file_exists_on_disk(dataset_file1) |
| 114 | + assert not self._file_exists_on_disk(dataset_file2) |
113 | 115 |
|
114 | 116 | def _get_underlying_dataset_on_disk(self, hda_id: str) -> Optional[str]: |
115 | 117 | detailed_response = self._get(f"datasets/{hda_id}", admin=True).json() |
116 | 118 | return detailed_response.get("file_name") |
117 | 119 |
|
118 | 120 | def _file_exists_on_disk(self, filename: Optional[str]) -> bool: |
119 | 121 | return os.path.isfile(filename) if filename else False |
120 | | - |
121 | | - def _wait_for_file_deleted(self, filename: Optional[str], timeout: int = 10): |
122 | | - def _check(): |
123 | | - return True if not self._file_exists_on_disk(filename) else None |
124 | | - |
125 | | - wait_on(_check, f"file {filename} to be deleted", timeout=timeout) |
0 commit comments