]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Added test casses and refactored test for Request#port
authorMax Shytikov <mshytikov@gmail.com>
Sun, 4 May 2014 00:20:46 +0000 (02:20 +0200)
committerMax Shytikov <mshytikov@gmail.com>
Sun, 4 May 2014 00:20:46 +0000 (02:20 +0200)
tests/unit/test_request.py

index 13f5271d023f180950b7cb8472fc739143ce8d27..ae0685ef84aebef9f8923eadcf9b94e6ca99b0ab 100644 (file)
@@ -1,3 +1,5 @@
+import pytest
+
 from vcr.request import Request
 
 
@@ -21,12 +23,17 @@ def test_flat_headers_dict():
     assert req.flat_headers_dict() == {'X-Header1': 'h1', 'X-Header2': 'h2'}
 
 
-def test_port():
-    req = Request('GET', 'http://go.com/', '', {})
-    assert req.port == 80
-
-    req = Request('GET', 'http://go.com:3000/', '', {})
-    assert req.port == 3000
+@pytest.mark.parametrize("uri, expected_port", [
+    ('http://go.com/', 80),
+    ('http://go.com:80/', 80),
+    ('http://go.com:3000/', 3000),
+    ('https://go.com/', 433),
+    ('https://go.com:433/', 433),
+    ('https://go.com:3000/', 3000),
+    ])
+def test_port(uri, expected_port):
+    req = Request('GET', uri,  '', {})
+    assert req.port == expected_port
 
 
 def test_uri():