Skip to content

Commit 786b167

Browse files
committed
Merge branch 'pr/331' into develop
2 parents 0f301b2 + b599328 commit 786b167

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

github3/repos/release.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def upload_asset(self, content_type, name, asset):
153153

154154

155155
class Asset(GitHubCore):
156+
156157
def _update_attributes(self, asset):
157158
self._api = asset.get('url')
158159
#: Content-Type provided when the asset was created
@@ -211,6 +212,20 @@ def download(self, path=''):
211212
return True
212213
return False
213214

215+
@requires_auth
216+
def delete(self):
217+
"""Delete this asset if the user has push access.
218+
219+
:returns: True if successful; False if not successful
220+
:rtype: boolean
221+
"""
222+
url = self._api
223+
return self._boolean(
224+
self._delete(url, headers=Release.CUSTOM_HEADERS),
225+
204,
226+
404
227+
)
228+
214229
def edit(self, name, label=None):
215230
"""Edit this asset.
216231

tests/cassettes/Asset_delete.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"recorded_with": "betamax/0.4.1", "http_interactions": [{"response": {"body": {"base64_string": "H4sIAAAAAAAAA+2by27rNhCGXyXQto4l+RI7AorTrtquehbpphuDlmmbOLqBpBz4CHn3zpCSdUko26K70yZQFM6vITVDcj4xhcN2TrBYvCzWs9nESUhMncA5MHnMt/NpdnYmzj6Pok37D9nZbTVJ3xPKnaBwovTAklpA2eMD/NV65i9fJg45EUn4JucRtDpKmYnAdfVNMdWauaA8TBNJEzkN09jN3dL62+nXOegdeCmCwg7c6IhlrBTS1qAmKm+VP0cZRx0H9INV+7JfuudpFKXvYN/1t/cR7r4yw8FT1yw5DJEAs8JN5ZHCgEE3PrDzTMg73VEmBXRMyA3boYiAV8Dp7j6XSiNwCF/2R+FymqVKLd+KkLNMsjS507WWKUil/EAS9pMMkAJTAQro1J1OKBMwpSeIuDtttU3hZpydSHjG4eA0pOwEoztEr2MMcvKcYUb+3RgZHHMm6YbsY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IYWD4B+JUs0K+9nbSJTavBN2Fi0cBWl5B1GCbRhOW4ViuPOV7618/zokhmI8JifGczFbtJHOJ07cbAqu4WNmC289h0lmECnWxhaguONQPyvuNL5kaf+WCwGDcFuDNDi/v1CxgcadN2fBjVtKj0PHbdkmeIbouZset9TuBcgtY7WNBBduIVpfvP/HYOSOR4a8/wfCDzy1J8idYGl8MXogRC5Z9g0U2ezOzSDZIHE3SzbpWONkk/CjiLJJ/26obBIaypVNeg9AyybpYXTZpGYJmE2yNozZpHkvZjbpQH1kQZr7VAfD5j7RYby5T3E4cjap2lFnk+pw8GxStGLPJtEmw8YF7D78bFJtyNSiNxPoK6pKB2TvAMYmxS4vhuyCWv1mtm2SxSTtSlegt38bq8mZSbfSsKLRJvEHAWmTvB2TNqsqrG2FpU3aQ8i0SesxcNqkPoxPm9QsELVJ0pJSm2QfBKpN8v8HqzY9ywZXmzRvINbzZ3/+5r8Gy3WwnH9FrDWOfnnzoM0yWHpGYr1681fB4iWYK6iNE6kuL+CqTawN3l6D1v1mV7h1v7HoQ9cGU+hjh15feglscQrfBnZwhmeXhgIZtqtqQ4TY6+UaDuw1vkRXxPoFbn/C2HjzGsjW6BeR9V0cW5u1MPbrrRx7Nr+AbLRpkWz8WwNlYw8+wewdlAFRmjlApkWa8xDGZaRhnz6CqO87zfCDIBppGA7KF7BnpGGfz+e2pq6RhpmOVI40TH9KvlZ7NE5pWpyvNKyn7kjDbj1raRrBkYaVG89bz12aBhLL95GGDTqDaRrSkYbBQVH4QjnSMH08eqRh6l+xxLATmqYsg1EdaZg70jCrY5um4BppmOePNMx4CmmkYXAe05aGJVS+w7/YVedFUa75Ra5khf7Hf09l/u9hPAAA", "string": "", "encoding": "utf-8"}, "headers": {"X-RateLimit-Reset": "1420689634", "X-Served-By": "4c8b2d4732c413f4b9aefe394bd65569", "Server": "GitHub.com", "Content-Security-Policy": "default-src 'none'", "Date": "Thu, 08 Jan 2015 03:32:38 GMT", "X-Frame-Options": "deny", "Content-Encoding": "gzip", "X-XSS-Protection": "1; mode=block", "X-GitHub-Request-Id": "48A0D428:4D46:11EAC6:54ADFA56", "Last-Modified": "Mon, 27 Oct 2014 21:07:08 GMT", "X-RateLimit-Remaining": "4917", "Cache-Control": "private, max-age=60, s-maxage=60", "X-Content-Type-Options": "nosniff", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Allow-Origin": "*", "Status": "200 OK", "Content-Type": "application/json; charset=utf-8", "Access-Control-Allow-Credentials": "true", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "ETag": "\"54bebaa14525ea91e2dd8f507232cd0e\"", "X-RateLimit-Limit": "5000", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Transfer-Encoding": "chunked"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/github3py/github3.py"}, "recorded_at": "2015-01-08T03:32:38", "request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"User-Agent": "github3.py/1.0.0a1", "Accept-Charset": "utf-8", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "uri": "https://api.github.com/repos/github3py/github3.py", "method": "GET"}}, {"response": {"body": {"base64_string": "H4sIAAAAAAAAA+1W0W7bIBT9lcjPdcB2qrRW12r/0L1smixsExsJAwKcLLHy77vYJEtYlbXZpL3kzYZ7DpcD93CHqNc8yqPWWmVyhIhi84bZti/nleyQpkoaNA1kanv4msOnppwSQw16yLIFXkZ3ETGGWlP8I0I00QFvr7gkdcA7DZrrkvXcw4sgHd3DEq3teLDAiQqX929Jg5I5nmOSABOro3xS5C6CmcKtAPr+CrBEN9QWoG7HLDMtTHbEWKoB7IM/c9WSmRd4JlezEQ3ztSYrG+Urwg0FvXvbSh3lQ8RlwwQQGdZ0ZM10b9KFzyVd4IcMQ/CawMrh4YyDBxF7Q3UlhaXCjoffown8sv6UAVujPYfbYuTO5dLNcWQGBQldljkIXknO5QZYwqTPr+jvC6EjEpKcvplormQB5ICkbSloB1tyl6Vh5k/X/I2kRtQAFWRswWrHY0B7TcOLHVTgG0weB2ltBGQ0jFU6EvalqTRTlknxcdXO0MAmdUME25Hr2ABtgGQ0kA9LP6IATddwFz8On2ADUpqtSbV10mhaUbYGsa+kDPDAaLfKFfYXuBROemZpQerOleFYnvu7SGnqa/hYspWmxEIWBKo4SnGyiJM0xsvXFOfJY54tvgKV6ksOvnASdR/jJMYPrzjL08ccP7oo7475t+FyHb7HwSculC0xTp3NuAKffo6W5C0QjD/2VharbQq/WSykoDER2/mm5QDmpKTwooie84N1g0I3kwrc8GZSN5MCb/vvJuUf/MLbGVGKs2r0fCQrS21sLHhW5yzOgnWBbU2dF61H19vBSIIX2X0K3Qm8R2OnVslegMFB1xH6XeBkiXOyXtVnnhjEZC6m1HIDRlsclzjvPd7dqx3wh4btpKG97Gv7766d0yXhYZ/4/o7Z40+axR1Tf8Xo8SeMpay3hWuz4KCe1POK7WZlv3tC6tmp6CYt/eEeHz/jR08G9j8BQ5ktjxMMAAA=", "string": "", "encoding": "utf-8"}, "headers": {"X-RateLimit-Reset": "1420689634", "X-Served-By": "139317cebd6caf9cd03889139437f00b", "Server": "GitHub.com", "Content-Security-Policy": "default-src 'none'", "Date": "Thu, 08 Jan 2015 03:32:38 GMT", "X-Frame-Options": "deny", "Content-Encoding": "gzip", "X-XSS-Protection": "1; mode=block", "X-GitHub-Request-Id": "48A0D428:4D46:11EAE5:54ADFA56", "Last-Modified": "Thu, 08 Jan 2015 03:29:09 GMT", "X-RateLimit-Remaining": "4916", "Cache-Control": "private, max-age=60, s-maxage=60", "X-Content-Type-Options": "nosniff", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Allow-Origin": "*", "Status": "200 OK", "Content-Type": "application/json; charset=utf-8", "Access-Control-Allow-Credentials": "true", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "ETag": "\"e788ec41f1a47cdccd4dfc829f6490bd\"", "X-RateLimit-Limit": "5000", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Transfer-Encoding": "chunked"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/github3py/github3.py/releases/833407"}, "recorded_at": "2015-01-08T03:32:38", "request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"User-Agent": "github3.py/1.0.0a1", "Accept-Charset": "utf-8", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "uri": "https://api.github.com/repos/github3py/github3.py/releases/833407", "method": "GET"}}, {"response": {"body": {"base64_string": "H4sIAAAAAAAAA51Uy26kMBD8F58BG5hos0jR/sTmkgvqAQcsGdvygxFB8+/bBhLNsNJIzM22usrV5S7PJFhJKtJ7b1xFKRiRdcL34Zw1eqCWG+3oelCa6XuV4dJyycFxR8E57h0tfzFWMJIQ0ZJq3SREwcCRfSNAWJpnLGOQp2YqcFumSiuegpqySy8RLOHMUY8KUiYkGKmh5ZZUM5G6EwqpnOgGGIUNrjhtlxUn9lqyhMAIHmy9a2g5dFtTwXHbaOW58kt/ga7gP+NbiWyd3ThiDwQPHpoTyRzdCer9IHcSbvzcFX9qKfUFWfai71/h/4voDxJFrmuhuidZEDlT7XuO3mFL12iEcP64qAU145A4X4s28jj03vL2sLANh7IuChXNyyAuhOHsGiuMF1odF3iHRjZtO1DiC55jQ7RDkiUjhztcUIjmI87icfgKm6mxYoRmitZY3nAxotlPUu7wyOgnE9P7jkMRrRee19AOMYafIB2/JmTLUr1VgjFSNIudVDee+9R5y2FYJ8FHsi3T7UL4hSc5O5UvRUJafOoY97rRQXlSYaAbxHpsCHBLCpa/pCxP2etfVlbF74rlH0gSTPuopow1Z6sv2EP9c8V9rG/y+fin+8bT7RO7+Q4f/2vXf71vFW9nBQAA", "string": "", "encoding": "utf-8"}, "headers": {"X-RateLimit-Reset": "1420689634", "X-Served-By": "a30e6f9aa7cf5731b87dfb3b9992202d", "Server": "GitHub.com", "Content-Security-Policy": "default-src 'none'", "Date": "Thu, 08 Jan 2015 03:32:39 GMT", "X-Frame-Options": "deny", "Content-Encoding": "gzip", "X-XSS-Protection": "1; mode=block", "X-GitHub-Request-Id": "48A0D428:4D46:11EAF4:54ADFA56", "Last-Modified": "Thu, 08 Jan 2015 03:29:03 GMT", "X-RateLimit-Remaining": "4915", "Cache-Control": "private, max-age=60, s-maxage=60", "X-Content-Type-Options": "nosniff", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Allow-Origin": "*", "Status": "200 OK", "Content-Type": "application/json; charset=utf-8", "Access-Control-Allow-Credentials": "true", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "ETag": "\"53c67a7b75b9191279b12d8a931fc9c6\"", "X-RateLimit-Limit": "5000", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Transfer-Encoding": "chunked"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/github3py/github3.py/releases/assets/370020"}, "recorded_at": "2015-01-08T03:32:39", "request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"User-Agent": "github3.py/1.0.0a1", "Accept-Charset": "utf-8", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "uri": "https://api.github.com/repos/github3py/github3.py/releases/assets/370020", "method": "GET"}}, {"response": {"body": {"string": "", "encoding": null}, "headers": {"Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1420689634", "Server": "GitHub.com", "Content-Security-Policy": "default-src 'none'", "Access-Control-Allow-Credentials": "true", "Date": "Thu, 08 Jan 2015 03:32:39 GMT", "Vary": "Accept-Encoding", "X-RateLimit-Limit": "5000", "X-XSS-Protection": "1; mode=block", "Status": "204 No Content", "X-GitHub-Request-Id": "48A0D428:4D46:11EB07:54ADFA57", "X-Served-By": "a241e1a8264a6ace03db946c85b92db3", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "X-Content-Type-Options": "nosniff", "X-GitHub-Media-Type": "github.v3; param=manifold-preview", "X-Frame-Options": "deny", "X-RateLimit-Remaining": "4914"}, "status": {"code": 204, "message": "No Content"}, "url": "https://api.github.com/repos/github3py/github3.py/releases/assets/370020"}, "recorded_at": "2015-01-08T03:32:39", "request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"User-Agent": "github3.py/1.0.0a1", "Accept-Charset": "utf-8", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.manifold-preview", "Content-Length": "0", "Content-Type": "application/json", "Connection": "keep-alive", "Authorization": "Basic <BASIC_AUTH>"}, "uri": "https://api.github.com/repos/github3py/github3.py/releases/assets/370020", "method": "DELETE"}}]}

tests/integration/test_repos_release.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def test_upload_asset(self):
6969

7070

7171
class TestAsset(IntegrationHelper):
72+
def test_delete(self):
73+
"""Test the ability to delete an asset."""
74+
self.basic_login()
75+
cassette_name = self.cassette_name('delete')
76+
with self.recorder.use_cassette(cassette_name):
77+
repository = self.gh.repository('github3py', 'github3.py')
78+
release = repository.release(833407)
79+
asset = release.asset(370020)
80+
assert asset.delete() is True
81+
7282
def test_download(self):
7383
"""Test the ability to download an asset."""
7484
cassette_name = self.cassette_name('download')

tests/unit/test_repos_release.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ class TestAsset(UnitHelper):
9191
"updated_at": "2013-02-27T19:35:32Z"
9292
}
9393

94+
def test_delete(self):
95+
"""Verify the request to delete an Asset."""
96+
self.instance.delete()
97+
98+
self.session.delete.assert_called_once_with(
99+
url_for('/assets/1'),
100+
headers=Release.CUSTOM_HEADERS
101+
)
102+
94103
@pytest.mark.xfail
95104
def test_download(self):
96105
"""Verify the request to download an Asset file."""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy