summaryrefslogtreecommitdiff
path: root/tests/test_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_client.py')
-rw-r--r--tests/test_client.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
deleted file mode 100644
index b22de034..00000000
--- a/tests/test_client.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import mock
-import httplib2
-from novaclient.client import OpenStackClient
-from nose.tools import assert_equal
-
-fake_response = httplib2.Response({"status": 200})
-fake_body = '{"hi": "there"}'
-mock_request = mock.Mock(return_value=(fake_response, fake_body))
-
-
-def client():
- cl = OpenStackClient("username", "apikey", "project_id", "auth_test")
- cl.management_url = "http://example.com"
- cl.auth_token = "token"
- return cl
-
-
-def test_get():
- cl = client()
-
- @mock.patch.object(httplib2.Http, "request", mock_request)
- @mock.patch('time.time', mock.Mock(return_value=1234))
- def test_get_call():
- resp, body = cl.get("/hi")
- mock_request.assert_called_with("http://example.com/hi?fresh=1234",
- "GET",
- headers={"X-Auth-Token": "token",
- "X-Auth-Project-Id": "project_id",
- "User-Agent": cl.USER_AGENT})
- # Automatic JSON parsing
- assert_equal(body, {"hi": "there"})
-
- test_get_call()
-
-
-def test_post():
- cl = client()
-
- @mock.patch.object(httplib2.Http, "request", mock_request)
- def test_post_call():
- cl.post("/hi", body=[1, 2, 3])
- mock_request.assert_called_with("http://example.com/hi", "POST",
- headers={
- "X-Auth-Token": "token",
- "X-Auth-Project-Id": "project_id",
- "Content-Type": "application/json",
- "User-Agent": cl.USER_AGENT},
- body='[1, 2, 3]'
- )
-
- test_post_call()