Skip to content

Instantly share code, notes, and snippets.

@roman-yepishev
Created October 12, 2014 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman-yepishev/07972bb870fc6b9cac95 to your computer and use it in GitHub Desktop.
Save roman-yepishev/07972bb870fc6b9cac95 to your computer and use it in GitHub Desktop.
MediaFire gzip test
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