-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with protected return, add tests, bump version
- Loading branch information
Showing
4 changed files
with
89 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "waifuvault" | ||
version = "1.2.4" | ||
version = "1.2.5" | ||
authors = [ | ||
{ name="Walker Aldridge", email="[email protected]" }, | ||
] | ||
|
@@ -24,3 +24,6 @@ classifiers = [ | |
[project.urls] | ||
Homepage = "https://github.com/waifuvault/waifuVault-python-api" | ||
Issues = "https://github.com/waifuvault/waifuVault-python-api/issues" | ||
|
||
[pytest] | ||
pythonpath = "src" |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import io | ||
import time | ||
|
||
import waifuvault | ||
|
||
|
||
# URL Upload Tests | ||
def test_upload_url(): | ||
upload_file = waifuvault.FileUpload("https://twistedsisterscleaning.walker.moe/assets/sunflowers.png", expires="10m") | ||
upload_res = waifuvault.upload_file(upload_file) | ||
assert (upload_res.url.startswith('http')), "not a URL returned" | ||
assert ('-' in upload_res.token), "not a token returned" | ||
time.sleep(1) | ||
|
||
upload_info = waifuvault.file_info(upload_res.token,True) | ||
assert ('seconds' in upload_info.retentionPeriod), "not a human readable timestamp returned" | ||
time.sleep(1) | ||
|
||
update_info = waifuvault.file_update(upload_res.token,"dangerWaifu") | ||
assert update_info.protected, "encryption returned false" | ||
time.sleep(1) | ||
|
||
file_down = waifuvault.get_file(upload_res,"dangerWaifu") | ||
assert (isinstance(file_down, io.BytesIO)), "not a buffer returned" | ||
assert (file_down.__sizeof__() > 0), "zero size buffer returned" | ||
time.sleep(1) | ||
|
||
del_file = waifuvault.delete_file(upload_res.token) | ||
assert del_file, "delete returned false" | ||
time.sleep(1) | ||
|
||
|
||
# File Upload Tests | ||
def test_upload_file(): | ||
upload_file = waifuvault.FileUpload("tests/testfile.png", expires="10m") | ||
upload_res = waifuvault.upload_file(upload_file) | ||
assert (upload_res.url.startswith('http')), "not a URL returned" | ||
assert ('-' in upload_res.token), "not a token returned" | ||
time.sleep(1) | ||
|
||
upload_info = waifuvault.file_info(upload_res.token,True) | ||
assert ('seconds' in upload_info.retentionPeriod), "not a human readable timestamp returned" | ||
time.sleep(1) | ||
|
||
update_info = waifuvault.file_update(upload_res.token,"dangerWaifu") | ||
assert update_info.protected, "encryption returned false" | ||
time.sleep(1) | ||
|
||
file_down = waifuvault.get_file(upload_res, "dangerWaifu") | ||
assert (isinstance(file_down, io.BytesIO)), "not a buffer returned" | ||
assert (file_down.__sizeof__() > 0), "zero size buffer" | ||
time.sleep(1) | ||
|
||
del_file = waifuvault.delete_file(upload_res.token) | ||
assert del_file, "delete file returned false" | ||
time.sleep(1) | ||
|
||
|
||
# Buffer Upload Tests | ||
def test_upload_buffer(): | ||
with open("tests/testfile.png", "rb") as fh: | ||
buf = io.BytesIO(fh.read()) | ||
upload_file = waifuvault.FileUpload(buf,"testfile_buf.png",expires="10m") | ||
upload_res = waifuvault.upload_file(upload_file) | ||
assert (upload_res.url.startswith('http')), "not a URL returned" | ||
assert ('-' in upload_res.token), "not a token returned" | ||
time.sleep(1) | ||
|
||
upload_info = waifuvault.file_info(upload_res.token,True) | ||
assert ('seconds' in upload_info.retentionPeriod), "not a human readable timestamp returned" | ||
time.sleep(1) | ||
|
||
update_info = waifuvault.file_update(upload_res.token,"dangerWaifu") | ||
assert update_info.protected, "encryption returned false" | ||
time.sleep(1) | ||
|
||
file_down = waifuvault.get_file(upload_res, "dangerWaifu") | ||
assert (isinstance(file_down, io.BytesIO)), "not a buffer returned" | ||
assert (file_down.__sizeof__() > 0), "zero size buffer" | ||
time.sleep(1) | ||
|
||
del_file = waifuvault.delete_file(upload_res.token) | ||
assert del_file | ||
time.sleep(1) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.