]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Tests for VCRHTTPResponse headers field.
authorRodrigo Taboada <rodrigo.taboada@myfreecomm.com.br>
Fri, 24 Oct 2014 19:40:51 +0000 (17:40 -0200)
committerRodrigo Taboada <rodrigo.taboada@myfreecomm.com.br>
Fri, 24 Oct 2014 19:40:51 +0000 (17:40 -0200)
tests/unit/test_response.py [new file with mode: 0644]

diff --git a/tests/unit/test_response.py b/tests/unit/test_response.py
new file mode 100644 (file)
index 0000000..503cf34
--- /dev/null
@@ -0,0 +1,68 @@
+# coding: UTF-8
+from vcr.stubs import VCRHTTPResponse
+
+
+def test_response_should_have_headers_field():
+    recorded_response = {
+        "status": {
+            "message": "OK",
+            "code": 200
+        },
+        "headers": {
+            "content-length": ["0"],
+            "server": ["gunicorn/18.0"],
+            "connection": ["Close"],
+            "access-control-allow-credentials": ["true"],
+            "date": ["Fri, 24 Oct 2014 18:35:37 GMT"],
+            "access-control-allow-origin": ["*"],
+            "content-type": ["text/html; charset=utf-8"],
+        },
+        "body": {
+            "string": ""
+        }
+    }
+    response = VCRHTTPResponse(recorded_response)
+
+    assert response.headers is not None
+
+
+def test_response_headers_should_be_equal_to_msg():
+    recorded_response = {
+        "status": {
+            "message": "OK",
+            "code": 200
+        },
+        "headers": {
+            "content-length": ["0"],
+            "server": ["gunicorn/18.0"],
+            "connection": ["Close"],
+            "content-type": ["text/html; charset=utf-8"],
+        },
+        "body": {
+            "string": ""
+        }
+    }
+    response = VCRHTTPResponse(recorded_response)
+
+    assert response.headers == response.msg
+
+
+def test_response_headers_should_have_correct_values():
+    recorded_response = {
+        "status": {
+            "message": "OK",
+            "code": 200
+        },
+        "headers": {
+            "content-length": ["10806"],
+            "date": ["Fri, 24 Oct 2014 18:35:37 GMT"],
+            "content-type": ["text/html; charset=utf-8"],
+        },
+        "body": {
+            "string": ""
+        }
+    }
+    response = VCRHTTPResponse(recorded_response)
+
+    assert response.headers.get('content-length') == "10806"
+    assert response.headers.get('date') == "Fri, 24 Oct 2014 18:35:37 GMT"