summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@rackspace.com>2011-07-13 11:59:27 -0500
committerDolph Mathews <dolph.mathews@rackspace.com>2011-07-13 11:59:27 -0500
commit39765dfd2f19d8565e83066672faf508e031cecc (patch)
tree6aca3c8a1da5eee11399eec577d3570070501474
parent02360171a41f7b0a644e5cfc557142ae365c6a2d (diff)
downloadkeystone-39765dfd2f19d8565e83066672faf508e031cecc.tar.gz
keystone-39765dfd2f19d8565e83066672faf508e031cecc.tar.xz
keystone-39765dfd2f19d8565e83066672faf508e031cecc.zip
Extracted sample test from framework and moved system test framework into __init__
-rw-r--r--keystone/test/system/__init__.py66
-rw-r--r--keystone/test/system/test.py70
-rw-r--r--keystone/test/system/test_content_types.py5
3 files changed, 71 insertions, 70 deletions
diff --git a/keystone/test/system/__init__.py b/keystone/test/system/__init__.py
index e69de29b..07a47844 100644
--- a/keystone/test/system/__init__.py
+++ b/keystone/test/system/__init__.py
@@ -0,0 +1,66 @@
+import unittest
+import httplib
+
+class RestfulTestCase(unittest.TestCase):
+ """Performs generic HTTP request testing"""
+
+ def setUp(self):
+ """Sets default connection settings"""
+ self.host = '127.0.0.1'
+ self.port = 80
+
+ def request(self, method='GET', path='/', headers={}, body=None,
+ expect_exception=False):
+ """Perform request and fetch httplib.HTTPResponse from the server"""
+
+ # Initialize a connection
+ connection = httplib.HTTPConnection(self.host, self.port, timeout=3)
+
+ # Perform the request
+ connection.request(method, path, body, headers)
+
+ # Retrieve the response so can go ahead and close the connection
+ response = connection.getresponse()
+
+ # Close the connection
+ connection.close()
+
+ # Automatically assert HTTP status code
+ if not expect_exception:
+ self.assertSuccessfulResponse(response.status)
+ else:
+ self.assertExceptionalResponse(response.status)
+
+ # This contains the response headers, body, etc
+ return response
+
+ def assertSuccessfulResponse(self, status_code):
+ """Asserts that a status code lies in the 2xx range"""
+ self.assertTrue(status_code >= 200 and status_code <= 299)
+
+ def assertExceptionalResponse(self, status_code):
+ """Asserts that a status code lies outside the 2xx range"""
+ self.assertTrue(status_code < 200 or status_code > 299)
+
+class ServiceTestCase(RestfulTestCase):
+ """Perform generic HTTP request testing against Service API"""
+
+ def setUp(self):
+ """Sets custom connection settings"""
+ super(ServiceTestCase, self).setUp()
+
+ # Override parent's connection settings
+ self.port = 5000 # The port the service API is expected to run on
+
+class AdminTestCase(RestfulTestCase):
+ """Perform generic HTTP request testing against Service API"""
+
+ def setUp(self):
+ """Sets custom connection settings"""
+ super(AdminTestCase, self).setUp()
+
+ # Override parent's connection settings
+ self.port = 5001 # The port the admin API is expected to run on
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/keystone/test/system/test.py b/keystone/test/system/test.py
deleted file mode 100644
index 39534837..00000000
--- a/keystone/test/system/test.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import unittest
-import httplib
-
-class RestfulTestCase(unittest.TestCase):
- """Performs generic HTTP request testing"""
-
- def setUp(self):
- """Sets default connection settings"""
- self.host = '127.0.0.1'
- self.port = 80
-
- def request(self, method='GET', path='/', headers={}, body=None,
- expect_exception=False):
- """Perform request and fetch httplib.HTTPResponse from the server"""
-
- # Initialize a connection
- connection = httplib.HTTPConnection(self.host, self.port, timeout=3)
-
- # Perform the request
- connection.request(method, path, body, headers)
-
- # Retrieve the response so can go ahead and close the connection
- response = connection.getresponse()
-
- # Close the connection
- connection.close()
-
- # Automatically assert HTTP status code
- if not expect_exception:
- self.assertSuccessfulResponse(response.status)
- else:
- self.assertExceptionalResponse(response.status)
-
- # This contains the response headers, body, etc
- return response
-
- def assertSuccessfulResponse(self, status_code):
- """Asserts that a status code lies in the 2xx range"""
- self.assertTrue(status_code >= 200 and status_code <= 299)
-
- def assertExceptionalResponse(self, status_code):
- """Asserts that a status code lies outside the 2xx range"""
- self.assertTrue(status_code < 200 or status_code > 299)
-
-class ServiceTestCase(RestfulTestCase):
- """Perform generic HTTP request testing against Service API"""
-
- def setUp(self):
- """Sets custom connection settings"""
- super(ServiceTestCase, self).setUp()
-
- # Override parent's connection settings
- self.port = 5000 # The port the service API is expected to run on
-
-class AdminTestCase(RestfulTestCase):
- """Perform generic HTTP request testing against Service API"""
-
- def setUp(self):
- """Sets custom connection settings"""
- super(AdminTestCase, self).setUp()
-
- # Override parent's connection settings
- self.port = 5001 # The port the admin API is expected to run on
-
-class TestContentTypes(AdminTestCase):
- def test_simple(self):
- self.request(path='/v2.0/')
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/keystone/test/system/test_content_types.py b/keystone/test/system/test_content_types.py
new file mode 100644
index 00000000..41d16513
--- /dev/null
+++ b/keystone/test/system/test_content_types.py
@@ -0,0 +1,5 @@
+from . import AdminTestCase
+
+class TestContentTypes(AdminTestCase):
+ def test_simple(self):
+ self.request(path='/v2.0/')