a few test fixtures for now
authorKenneth Reitz <me@kennethreitz.com>
Mon, 14 Feb 2011 04:51:37 +0000 (23:51 -0500)
committerKenneth Reitz <me@kennethreitz.com>
Mon, 14 Feb 2011 04:51:37 +0000 (23:51 -0500)
test_requests.py

index 9fe182f..0bd6c96 100644 (file)
@@ -5,7 +5,43 @@ import unittest
 
 import requests
 
-print requests.get('http://kennethreitz.com').headers
 
+class RequestsTestSuite(unittest.TestCase):
+       """Requests test cases."""
+       
+       def setUp(self):
+               pass
 
-r = requests.Request()
\ No newline at end of file
+       def tearDown(self):
+               """Teardown."""
+               pass
+               
+       def test_invalid_url(self):
+               self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')
+
+       def test_HTTP_200_OK_GET(self):
+               r = requests.get('http://google.com')
+               self.assertEqual(r.status_code, 200)
+
+       def test_HTTPS_200_OK_GET(self):
+               r = requests.get('https://google.com')
+               self.assertEqual(r.status_code, 200)
+
+       def test_HTTP_200_OK_HEAD(self):
+               r = requests.head('http://google.com')
+               self.assertEqual(r.status_code, 200)
+
+       def test_HTTPS_200_OK_HEAD(self):
+               r = requests.head('https://google.com')
+               self.assertEqual(r.status_code, 200)
+
+       def test_AUTH_HTTPS_200_OK_GET(self):
+               auth = requests.AuthObject('requeststest', 'requeststest')
+               url = 'https://convore.com/api/account/verify.json'
+               r = requests.get(url, auth=auth)
+
+               self.assertEqual(r.status_code, 200)
+
+
+if __name__ == '__main__':
+       unittest.main()