Skip to content

Commit

Permalink
Merge pull request #24 from waifuvault/add-long-test
Browse files Browse the repository at this point in the history
Add test for handling a long numeric retention period
  • Loading branch information
nakedmcse authored Sep 12, 2024
2 parents e2445b5 + 99eb36b commit b95ff6d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_waifuvault.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def __init__(self, ok, text, content=None, code=None):


# Mocked responses
ok_response_numeric_long = response_mock(True,
'{"url":"https://waifuvault.moe/f/something", "token":"test-token", "bucket":"test-bucket", "retentionPeriod":28860366525, "options":{"protected": false, "oneTimeDownload": false, "hideFilename": false}}')
ok_response_numeric = response_mock(True,
'{"url":"https://waifuvault.moe/f/something", "token":"test-token", "bucket":"test-bucket", "retentionPeriod":100, "options":{"protected": false, "oneTimeDownload": false, "hideFilename": false}}')
ok_response_numeric_protected = response_mock(True,
Expand Down Expand Up @@ -180,6 +182,23 @@ def test_file_info(mocker):
assert (upload_info.retentionPeriod == "10 minutes"), "Retention does not match"


def test_file_info_long(mocker):
# Given
mock_get = mocker.patch('requests.get', return_value = ok_response_numeric_long)

# When
upload_info = waifuvault.file_info("test-token",False)

# Then
mock_get.assert_called_once_with(
'https://waifuvault.moe/rest/test-token',
params={'formatted': 'false'})
assert (upload_info.url == "https://waifuvault.moe/f/something"), "URL does not match"
assert (upload_info.token == "test-token"), "Token does not match"
assert (upload_info.options.protected is False), "Protected does not match"
assert (upload_info.retentionPeriod == 28860366525), "Retention does not match"


def test_file_info_error(mocker):
# When
mock_get = mocker.patch('requests.get', return_value = bad_request)
Expand Down

0 comments on commit b95ff6d

Please sign in to comment.