mirror of
https://github.com/caronc/apprise.git
synced 2025-06-22 02:31:41 +02:00
apprise-api python 3 compatibility bugfix (#239)
This commit is contained in:
parent
3af32412df
commit
73046207d5
@ -211,7 +211,7 @@ class ConfigHTTP(ConfigBase):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Store our result (but no more than our buffer length)
|
# Store our result (but no more than our buffer length)
|
||||||
response = r.content[:self.max_buffer_size + 1]
|
response = r.text[:self.max_buffer_size + 1]
|
||||||
|
|
||||||
# Verify that our content did not exceed the buffer size:
|
# Verify that our content did not exceed the buffer size:
|
||||||
if len(response) > self.max_buffer_size:
|
if len(response) > self.max_buffer_size:
|
||||||
|
@ -89,7 +89,7 @@ def test_config_http(mock_post):
|
|||||||
'Content-Type': 'text/plain',
|
'Content-Type': 'text/plain',
|
||||||
}
|
}
|
||||||
|
|
||||||
content = default_content
|
text = default_content
|
||||||
|
|
||||||
# Pointer to file
|
# Pointer to file
|
||||||
ptr = None
|
ptr = None
|
||||||
@ -257,7 +257,7 @@ def test_config_http(mock_post):
|
|||||||
iter(ch)
|
iter(ch)
|
||||||
|
|
||||||
# Test a buffer size limit reach
|
# Test a buffer size limit reach
|
||||||
ch.max_buffer_size = len(dummy_response.content)
|
ch.max_buffer_size = len(dummy_response.text)
|
||||||
assert isinstance(ch.read(), six.string_types) is True
|
assert isinstance(ch.read(), six.string_types) is True
|
||||||
|
|
||||||
# Test YAML detection
|
# Test YAML detection
|
||||||
@ -304,7 +304,7 @@ def test_config_http(mock_post):
|
|||||||
# Take a snapshot
|
# Take a snapshot
|
||||||
max_buffer_size = ch.max_buffer_size
|
max_buffer_size = ch.max_buffer_size
|
||||||
|
|
||||||
ch.max_buffer_size = len(dummy_response.content) - 1
|
ch.max_buffer_size = len(dummy_response.text) - 1
|
||||||
assert ch.read() is None
|
assert ch.read() is None
|
||||||
|
|
||||||
# Restore buffer size count
|
# Restore buffer size count
|
||||||
@ -321,12 +321,12 @@ def test_config_http(mock_post):
|
|||||||
assert isinstance(ch.read(), six.string_types) is True
|
assert isinstance(ch.read(), six.string_types) is True
|
||||||
|
|
||||||
# Handle cases where the content length is exactly at our limit
|
# Handle cases where the content length is exactly at our limit
|
||||||
dummy_response.content = 'a' * ch.max_buffer_size
|
dummy_response.text = 'a' * ch.max_buffer_size
|
||||||
# This is acceptable
|
# This is acceptable
|
||||||
assert isinstance(ch.read(), six.string_types) is True
|
assert isinstance(ch.read(), six.string_types) is True
|
||||||
|
|
||||||
# If we are over our limit though..
|
# If we are over our limit though..
|
||||||
dummy_response.content = 'b' * (ch.max_buffer_size + 1)
|
dummy_response.text = 'b' * (ch.max_buffer_size + 1)
|
||||||
assert ch.read() is None
|
assert ch.read() is None
|
||||||
|
|
||||||
# Test an invalid return code
|
# Test an invalid return code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user