-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for customising the Dropbox filename
- Loading branch information
Showing
8 changed files
with
63 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
arrow | ||
dropbox | ||
jinja2 | ||
requests | ||
retrace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import datetime | ||
import logging | ||
import pathlib | ||
|
||
from dropbox_upload import backup | ||
|
||
|
||
def test_local_path(): | ||
expected = pathlib.Path("/backup/SLUG.tar") | ||
assert backup.local_path({"slug": "SLUG"}) == expected | ||
|
||
|
||
def test_dropbox_path(cfg): | ||
cfg["dropbox_dir"] = "/dropbox_dir" | ||
expected = pathlib.Path("/dropbox_dir/SLUG.tar") | ||
assert backup.dropbox_path(cfg, {"slug": "SLUG"}) == expected | ||
|
||
|
||
def test_backup_no_snapshots(cfg, caplog): | ||
backup.backup(None, cfg, []) | ||
|
||
assert ( | ||
"dropbox_upload.backup", | ||
logging.WARNING, | ||
"No snapshots found to backup", | ||
) in caplog.record_tuples | ||
|
||
|
||
def test_dropbox_path_date_filenames(cfg): | ||
cfg["filename_fmt"] = "{{date}} {{slug}} {{name}}" | ||
cfg["dropbox_dir"] = "/dropbox_dir" | ||
expected = pathlib.Path( | ||
"/dropbox_dir/2018-09-13 19.50.22 SLUG Automated backup.tar" | ||
) | ||
snapshot = { | ||
"slug": "SLUG", | ||
"name": "Automated backup", | ||
"date": datetime.datetime(2018, 9, 13, 19, 50, 22).isoformat(), | ||
} | ||
result = backup.dropbox_path(cfg, snapshot) | ||
assert result == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters