Repository: falconry/falcon
Pull request #1290 (2018-05-14 20:08:11)

refactor(request) Remove Deprecated Request Aliases
This is a breaking Change.
This PR supports (but does not complete) #1029 


codecov[bot]: # [Codecov](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@043b588`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/falconry/falcon/pull/1290/graphs/tree.svg?token=zOtkfNQ3h6&src=pr&width=650&height=150)](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master    #1290   +/-   ##
=========================================
  Coverage          ?   97.51%           
=========================================
  Files             ?       39           
  Lines             ?     2533           
  Branches          ?      384           
=========================================
  Hits              ?     2470           
  Misses            ?       50           
  Partials          ?       13
```


| [Impacted Files](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [falcon/request.py](https://codecov.io/gh/falconry/falcon/pull/1290/diff?src=pr&el=tree#diff-ZmFsY29uL3JlcXVlc3QucHk=) | `98.84% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=footer). Last update [043b588...e4471cc](https://codecov.io/gh/falconry/falcon/pull/1290?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/falcon/request.py b/falcon/request.py
index 430bb32..f3f7a9d 100644
--- a/falcon/request.py
+++ b/falcon/request.py
@@ -117,8 +117,6 @@ class Request(object):
 
             (See also: RFC 7239, Section 1)
 
-        protocol (str): Deprecated alias for `scheme`. Will be removed
-            in a future release.
         method (str): HTTP method requested (e.g., 'GET', 'POST', etc.)
         host (str): Host request header field
         forwarded_host (str): Original host request header as received
@@ -714,18 +712,13 @@ class Request(object):
 
         return scheme
 
-    # TODO(kgriffs): Remove this deprecated alias in Falcon 2.0
-    protocol = scheme
-
     @property
     def uri(self):
         if self._cached_uri is None:
-            scheme = self.env['wsgi.url_scheme']
-
             # PERF: For small numbers of items, '+' is faster
             # than ''.join(...). Concatenation is also generally
             # faster than formatting.
-            value = (scheme + '://' +
+            value = (self.scheme + '://' +
                      self.netloc +
                      self.relative_uri)
 
@@ -926,8 +919,6 @@ class Request(object):
     @property
     def netloc(self):
         env = self.env
-        protocol = env['wsgi.url_scheme']
-
         # NOTE(kgriffs): According to PEP-3333 we should first
         # try to use the Host header if present.
         #
@@ -939,7 +930,7 @@ class Request(object):
             netloc_value = env['SERVER_NAME']
 
             port = env['SERVER_PORT']
-            if protocol == 'https':
+            if self.scheme == 'https':
                 if port != '443':
                     netloc_value += ':' + port
             else:
@@ -1646,14 +1637,6 @@ class Request(object):
 
         return val
 
-    get_param_as_dict = get_param_as_json
-    """Deprecated alias of :meth:`~get_param_as_json`.
-
-    Warning:
-
-        This method has been deprecated and will be removed in a future release.
-    """
-
     def has_param(self, name):
         """Determine whether or not the query string parameter already exists.
 


Test patch:
diff --git a/tests/test_query_params.py b/tests/test_query_params.py
index 9c85f3b..386c4aa 100644
--- a/tests/test_query_params.py
+++ b/tests/test_query_params.py
@@ -760,7 +760,7 @@ class TestQueryParams(object):
         query_string = 'payload={}'.format(json.dumps(payload_dict))
         simulate_request(client=client, path='/', query_string=query_string)
         req = resource.captured_req
-        assert req.get_param_as_dict('payload') == payload_dict
+        assert req.get_param_as_json('payload') == payload_dict
 
     def test_get_dict_missing_param(self, simulate_request, client, resource):
         client.app.add_route('/', resource)
@@ -768,7 +768,7 @@ class TestQueryParams(object):
         query_string = 'notthepayload={}'.format(json.dumps(payload_dict))
         simulate_request(client=client, path='/', query_string=query_string)
         req = resource.captured_req
-        assert req.get_param_as_dict('payload') is None
+        assert req.get_param_as_json('payload') is None
 
     def test_get_dict_store(self, simulate_request, client, resource):
         client.app.add_route('/', resource)
@@ -777,7 +777,7 @@ class TestQueryParams(object):
         simulate_request(client=client, path='/', query_string=query_string)
         req = resource.captured_req
         store = {}
-        req.get_param_as_dict('payload', store=store)
+        req.get_param_as_json('payload', store=store)
         assert len(store) != 0
 
     def test_get_dict_invalid(self, simulate_request, client, resource):
@@ -787,7 +787,7 @@ class TestQueryParams(object):
         simulate_request(client=client, path='/', query_string=query_string)
         req = resource.captured_req
         with pytest.raises(HTTPInvalidParam):
-            req.get_param_as_dict('payload')
+            req.get_param_as_json('payload')
 
     def test_has_param(self, simulate_request, client, resource):
         client.app.add_route('/', resource)
diff --git a/tests/test_request_attrs.py b/tests/test_request_attrs.py
index f9e73a8..cd6db82 100644
--- a/tests/test_request_attrs.py
+++ b/tests/test_request_attrs.py
@@ -100,7 +100,7 @@ class TestRequestAttributes(object):
     def test_reconstruct_url(self):
         req = self.req
 
-        scheme = req.protocol
+        scheme = req.scheme
         host = req.get_header('host')
         app = req.app
         path = req.path