Repository: brettcannon/gidgethub
Pull request #54 (2018-03-20 02:26:04)

Add ``data`` keyword argument to gidgethub.abc.GitHubAPI.delete
Closes https://github.com/brettcannon/gidgethub/issues/52

codecov[bot]: # [Codecov](https://codecov.io/gh/brettcannon/gidgethub/pull/54?src=pr&el=h1) Report
> Merging [#54](https://codecov.io/gh/brettcannon/gidgethub/pull/54?src=pr&el=desc) into [master](https://codecov.io/gh/brettcannon/gidgethub/commit/e2e35fd522bc1830bf4fcbf9ec889d25742d5cef?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/brettcannon/gidgethub/pull/54/graphs/tree.svg?src=pr&token=t1zJsj2sZH&width=650&height=150)](https://codecov.io/gh/brettcannon/gidgethub/pull/54?src=pr&el=tree)

```diff
@@          Coverage Diff          @@
##           master    #54   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          14     14           
  Lines        1023   1030    +7     
  Branches       58     58           
=====================================
+ Hits         1023   1030    +7
```


| [Impacted Files](https://codecov.io/gh/brettcannon/gidgethub/pull/54?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [gidgethub/test/test\_abc.py](https://codecov.io/gh/brettcannon/gidgethub/pull/54/diff?src=pr&el=tree#diff-Z2lkZ2V0aHViL3Rlc3QvdGVzdF9hYmMucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [gidgethub/abc.py](https://codecov.io/gh/brettcannon/gidgethub/pull/54/diff?src=pr&el=tree#diff-Z2lkZ2V0aHViL2FiYy5weQ==) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/brettcannon/gidgethub/pull/54?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/brettcannon/gidgethub/pull/54?src=pr&el=footer). Last update [e2e35fd...1134acc](https://codecov.io/gh/brettcannon/gidgethub/pull/54?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/README.rst b/README.rst
index 24ca94e..7b247ba 100644
--- a/README.rst
+++ b/README.rst
@@ -1,5 +1,5 @@
 gidgethub
-==========
+=========
 An asynchronous `GitHub API <https://developer.github.com/>`_ library.
 
 
@@ -69,9 +69,11 @@ Changelog
 - Provide a human-readable string representation of
   ``gidgethub.sansio.RateLimit``.
   
-- Use the `message` data as the error message, if the `errors` object
+- Use the ``message`` data as the error message, if the ``errors`` object
   was not returned.
 
+- Add *data* keyword argument to ``gidgethub.abc.GitHubAPI.delete``.
+
 
 2.4.1
 '''''
@@ -80,13 +82,13 @@ Changelog
 
 
 2.4.0
-''''''''''''''''''''''
+'''''
 
 - Expand ``gidgethub.routing.Router.dispatch()``.
 
 
 2.3.0
-''''''''''''''''''''''
+'''''
 
 - Add support for ``application/x-www-form-urlencoded`` webhook event payloads.
   (This also allows for API calls to return this content type, although GitHub
@@ -101,7 +103,7 @@ Changelog
 
 
 2.2.0
-'''''''''''''''''''
+'''''
 
 - Introduce ``gidgethub.tornado`` to support
   `Tornado <http://www.tornadoweb.org/>`_ (thanks to
@@ -109,7 +111,7 @@ Changelog
 
 
 2.1.0
-''''''''''''''''''''''
+'''''
 
 - The default value for the *data* argument of ``gidgethub.abc.GitHubAPI.put()``
   was changed from ``""`` to ``b""``.
@@ -118,7 +120,7 @@ Changelog
 
 
 2.0.0
-''''''''''''''''''''''
+'''''
 
 - Renamed ``gidgethub.abc._sleep()`` to ``sleep()`` to make the method public.
 - Renamed the "test" extra to "tests" and added the "dev" extra.
@@ -130,7 +132,7 @@ Changelog
 
 
 1.2.0
-''''''''''''''''''''''
+'''''
 
 - ``gidgethub.sansio.Event.from_http()`` raises a ``BadRequest`` of ``415``
   instead of ``400`` when a content-type other than ``application/json``
@@ -139,7 +141,7 @@ Changelog
   (i.e. if the ``content-type`` doesn't specify ``charset``, assume ``UTF-8``).
 - Changed the signature of ``gidgethub.sansio.Event`` to accept ``Any`` for
   the *data* argument.
-- Fixed signature verification
+- Fixed signature verification.
 
 
 1.1.0
diff --git a/docs/abc.rst b/docs/abc.rst
index f629e8b..42aa3f3 100644
--- a/docs/abc.rst
+++ b/docs/abc.rst
@@ -151,6 +151,6 @@ experimental APIs without issue.
         will return no content, leading to ``None`` being returned.
 
 
-    .. coroutine:: delete(url, url_vars={}, *, accept=sansio.accept_format())
+    .. coroutine:: delete(url, url_vars={}, *, data=b"", accept=sansio.accept_format())
 
         Send a ``DELETE`` request to GitHub.
diff --git a/gidgethub/abc.py b/gidgethub/abc.py
index 4b4bf99..d0180b5 100644
--- a/gidgethub/abc.py
+++ b/gidgethub/abc.py
@@ -104,6 +104,6 @@ class GitHubAPI(abc.ABC):
         data, _ = await self._make_request("PUT", url, url_vars, data, accept)
         return data
 
-    async def delete(self, url: str, url_vars: Dict = {}, *,
+    async def delete(self, url: str, url_vars: Dict = {}, *, data: Any = b"",
                      accept: str = sansio.accept_format()) -> None:
-        await self._make_request("DELETE", url, url_vars, b"", accept)
+        await self._make_request("DELETE", url, url_vars, data, accept)


Test patch:
diff --git a/gidgethub/test/test_abc.py b/gidgethub/test/test_abc.py
index 5d01546..a7baaa4 100644
--- a/gidgethub/test/test_abc.py
+++ b/gidgethub/test/test_abc.py
@@ -182,10 +182,18 @@ async def test_put():
 
 @pytest.mark.asyncio
 async def test_delete():
-    gh = MockGitHubAPI()
-    data = await gh.delete("/fake")
+    send = [1, 2, 3]
+    send_json = json.dumps(send).encode("utf-8")
+    receive = {"hello": "world"}
+    headers = MockGitHubAPI.DEFAULT_HEADERS.copy()
+    headers['content-type'] = "application/json; charset=utf-8"
+    gh = MockGitHubAPI(headers=headers,
+                       body=json.dumps(receive).encode("utf-8"))
+    data = await gh.delete("/fake", data=send)
     assert gh.method == "DELETE"
-    assert data is None
+    assert gh.headers['content-type'] == "application/json; charset=utf-8"
+    assert gh.body == send_json
+    assert gh.headers['content-length'] == str(len(send_json))
 
 
 class TestCache: