Skip to content

Commit be96690

Browse files
committed
fix: SeaDexBackup.create() now returns BackupFile
1 parent 1550bb6 commit be96690

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/seadex/_backup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def download(self, file: StrPath | BackupFile | None = None, *, destination: Str
152152

153153
return outfile
154154

155-
def create(self, filename: StrPath | None = None) -> str:
155+
def create(self, filename: StrPath | None = None) -> BackupFile:
156156
"""
157157
Creates a new backup with an optional filename.
158158
@@ -165,8 +165,8 @@ def create(self, filename: StrPath | None = None) -> str:
165165
166166
Returns
167167
-------
168-
str
169-
The name of the newly created backup file.
168+
BackupFile
169+
The newly created backup file.
170170
"""
171171
datefmt = "%Y%m%d%H%M%S"
172172
name = f"{datefmt}-seadex-backup.zip"
@@ -179,7 +179,7 @@ def create(self, filename: StrPath | None = None) -> str:
179179

180180
self.client.backups.create(_filename)
181181

182-
return _filename
182+
return next(filter(lambda member: member.name == _filename, self.backups))
183183

184184
def delete(self, file: StrPath | BackupFile) -> None:
185185
"""

tests/test_backup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ def test_backup_download_with_pathlike(tmp_path: Path) -> None:
8585
def test_backup_create() -> None:
8686
client = SeaDexBackup(email, password) # type: ignore
8787
new_backup = client.create(Path(f"{uuid4()}-made-by-pytest.zip"))
88-
assert new_backup in [backup.name for backup in client.backups]
88+
assert new_backup in [backup for backup in client.backups]
8989
client.delete(new_backup)
90-
assert new_backup not in [backup.name for backup in client.backups]
90+
assert new_backup not in [backup for backup in client.backups]

0 commit comments

Comments
 (0)