|
11 | 11 | from aiohasupervisor.models import ( |
12 | 12 | BackupsOptions, |
13 | 13 | Folder, |
| 14 | + FreezeOptions, |
14 | 15 | FullBackupOptions, |
15 | 16 | PartialBackupOptions, |
16 | 17 | PartialRestoreOptions, |
@@ -78,12 +79,15 @@ async def test_backups_reload( |
78 | 79 | } |
79 | 80 |
|
80 | 81 |
|
| 82 | +@pytest.mark.parametrize("options", [None, FreezeOptions(timeout=1000)]) |
81 | 83 | async def test_backups_freeze( |
82 | | - responses: aioresponses, supervisor_client: SupervisorClient |
| 84 | + responses: aioresponses, |
| 85 | + supervisor_client: SupervisorClient, |
| 86 | + options: FreezeOptions | None, |
83 | 87 | ) -> None: |
84 | 88 | """Test backups freeze API.""" |
85 | 89 | responses.post(f"{SUPERVISOR_URL}/backups/freeze", status=200) |
86 | | - assert await supervisor_client.backups.freeze() is None |
| 90 | + assert await supervisor_client.backups.freeze(options) is None |
87 | 91 | assert responses.requests.keys() == { |
88 | 92 | ("POST", URL(f"{SUPERVISOR_URL}/backups/freeze")) |
89 | 93 | } |
@@ -120,31 +124,33 @@ async def test_partial_restore_options() -> None: |
120 | 124 |
|
121 | 125 | def backup_callback(url: str, **kwargs: dict[str, Any]) -> CallbackResult: # noqa: ARG001 |
122 | 126 | """Return response based on whether backup was in background or not.""" |
123 | | - if kwargs["json"]["background"]: |
| 127 | + if kwargs["json"] and kwargs["json"]["background"]: |
124 | 128 | fixture = "backup_background.json" |
125 | 129 | else: |
126 | 130 | fixture = "backup_foreground.json" |
127 | 131 | return CallbackResult(status=200, body=load_fixture(fixture)) |
128 | 132 |
|
129 | 133 |
|
130 | 134 | @pytest.mark.parametrize( |
131 | | - ("background", "slug"), |
132 | | - [(True, None), (False, "9ecf0028")], |
| 135 | + ("options", "slug"), |
| 136 | + [ |
| 137 | + (FullBackupOptions(name="Test", background=True), None), |
| 138 | + (FullBackupOptions(name="Test", background=False), "9ecf0028"), |
| 139 | + (None, "9ecf0028"), |
| 140 | + ], |
133 | 141 | ) |
134 | 142 | async def test_backups_full_backup( |
135 | 143 | responses: aioresponses, |
136 | 144 | supervisor_client: SupervisorClient, |
137 | | - background: bool, # noqa: FBT001 |
| 145 | + options: FullBackupOptions | None, |
138 | 146 | slug: str | None, |
139 | 147 | ) -> None: |
140 | 148 | """Test backups full backup API.""" |
141 | 149 | responses.post( |
142 | 150 | f"{SUPERVISOR_URL}/backups/new/full", |
143 | 151 | callback=backup_callback, |
144 | 152 | ) |
145 | | - result = await supervisor_client.backups.full_backup( |
146 | | - FullBackupOptions(name="test", background=background) |
147 | | - ) |
| 153 | + result = await supervisor_client.backups.full_backup(options) |
148 | 154 | assert result.job_id == "dc9dbc16f6ad4de592ffa72c807ca2bf" |
149 | 155 | assert result.slug == slug |
150 | 156 |
|
|
0 commit comments