Created
October 12, 2014 15:52
-
-
Save roman-yepishev/07972bb870fc6b9cac95 to your computer and use it in GitHub Desktop.
MediaFire gzip test
This file contains hidden or 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
import requests | |
import unittest | |
API_BASE = 'https://www.mediafire.com/api' | |
class MediaFireGzipTest(unittest.TestCase): | |
"""Test MediaFire gzipped content response""" | |
def test_api_1_0_gzip(self): | |
response = requests.get(API_BASE + '/1.0/system/get_status.php?' | |
'response_format=json') | |
self.assertEqual(response.status_code, requests.codes.ok, | |
'200 OK') | |
self.assertNotEqual(response.text[:1], '\x1f', | |
'Got non-decoded gzipped content') | |
self.assertEqual(response.headers['Content-Encoding'], 'gzip', | |
'Content-Encoding header set') | |
self.assertTrue(response.json()) | |
def test_api_1_1_gzip(self): | |
response = requests.post(API_BASE + '/1.1/system/get_status.php?' | |
'response_format=json') | |
self.assertEqual(response.status_code, requests.codes.ok, | |
'200 OK') | |
self.assertNotEqual(response.text[:1], '\x1f', | |
'Got non-decoded gzipped content') | |
self.assertEqual(response.headers.get('Content-Encoding'), 'gzip', | |
'Content-Encoding header set') | |
self.assertTrue(response.json()) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment