8000 Add main class of Projects API · pythonthings/github3.py@690dc55 · GitHub
[go: up one dir, main page]

Skip to content

Commit 690dc55

Browse files
rco-abletonsigmavirus24
authored andcommitted
Add main class of Projects API
1 parent 856ec18 commit 690dc55

File tree

6 files changed

+202
-0
lines changed

6 files changed

+202
-0
lines changed

github3/projects.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
github3.projects
4+
=============
5+
6+
This module contains all the classes relating to projects.
7+
"""
8+
from json import dumps
9+
10+
from . import models
11+
from . import users
12+
from .decorators import requires_auth
13+
14+
15+
class Project(models.GitHubCore):
16+
"""The :class:`Project <Project>` object.
17+
18+
See http://developer.github.com/v3/projects/
19+
"""
20+
21+
CUSTOM_HEADERS = {
22+
'Accept': 'application/vnd.github.inertia-preview+json',
23+
}
24+
25+
def _update_attributes(self, project):
26+
self._api = self._get_attribute(project, 'url')
27+
28+
#: The body of the project
29+
self.body = self._get_attribute(project, 'body')
30+
31+
#: datetime object representing when the project was created
32+
self.created_at = self._strptime_attribute(project, 'created_at')
33+
34+
#: The user who created this project
35+
self.creator = self._class_attribute(
36+
project, 'creator', users.ShortUser, self,
37+
)
38+
39+
#: The unique ID of the project
40+
self.id = self._get_attribute(project, 'id')
41+
42+
#: The name of this project
43+
self.name = self._get_attribute(project, 'name')
44+
45+
#: The number of the project
46+
self.number = self._get_attribute(project, 'number')
47+
48+
#: The owner repo or organisation of this project
49+
self.owner_url = self._get_attribute(project, 'owner_url')
50+
51+
#: datetime object representing the last time the object was changed
52+
self.updated_at = self._strptime_attribute(project, 'updated_at')
53+
54+
def _repr(self):
55+
return '<Project [#{0}]>'.format(self.id)
56+
57+
@requires_auth
58+
def delete(self):
59+
"""Delete this project.
60+
61+
:returns: bool
62+
"""
63+
return self._boolean(self._delete(
64+
self._api, headers=self.CUSTOM_HEADERS), 204, 404)
65+
66+
@requires_auth
67+
def update(self, name=None, body=None):
68+
"""Update this project.
69+
70+
:param str name: (optional), name of the project
71+
:param str body: (optional), body of the project
72+
:returns: bool
73+
"""
74+
data = {'name': name, 'body': body}
75+
json = None
76+
self._remove_none(data)
77+
78+
if data:
79+
json = self._json(self._patch(
80+
self._api, data=dumps(data), headers=self.CUSTOM_HEADERS), 200)
81+
82+
if json:
83+
self._update_attributes(json)
84+
return True
85+
return False
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"recorded_with": "betamax/0.8.0", "http_interactions": [{"response": {"headers": {"X-GitHub-Request-Id": "F446:7033:B77E53D:E3216ED:58AC2B4E", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "ETag": "W/\"f2528211d57d91b73858bae183c81d71\"", "X-RateLimit-Limit": "5000", "X-OAuth-Scopes": "repo", "X-Served-By": "a30e6f9aa7cf5731b87dfb3b9992202d", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Reset": "1487680319", "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-XSS-Protection": "1; mode=block", "Content-Encoding": "gzip", "Access-Control-Allow-Origin": "*", "X-GitHub-Media-Type": "github.drax-preview; format=json", "Date": "Tue, 21 Feb 2017 11:58:06 GMT", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Remaining": "4981", "Content-Security-Policy": "default-src 'none'", "X-Frame-Options": "deny", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-Content-Type-Options": "nosniff", "Transfer-Encoding": "chunked", "Last-Modified": "Tue, 15 Nov 2016 14:09:50 GMT", "X-Accepted-OAuth-Scopes": "repo"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py", "body": {"string": "", "encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+2YTW/jNhCG/4qhax3Tjrtx10CxLdB7L3vqxaAl2iJCkQJJ2U2E/Pe+I+rLDnblNffQQ4AgsRXy4avhDDkzdSKzZLtZ/7b6vFlv5onmhUi2iRfOW1GaZJ4cKqV27eM/90p4o/8Sp6/GKMdGw8xZC5ts60SZo9RAXI0FiVZarZ+e8LOaJ/zEPbe7yioMzr0v3Zax8NAtjtLn1b5ywqZGe6H9IjUFq1g3/cvp9zWIR9tSCJ3gwRWtlC0pTAfOsfe6cl+oKx1h/WbW+/EHo5Q5g3Ut/oblWD+ZTNuApD7eD8LkmhmfC1gSr/dGRpHO3yWtmVgz+rOTGaEcdsiK7B557VSII8d4qxm5U8Os9i61svTS6LtkXgAANPbItXzldwMBcOCQwLsENRMBECc46l2EMLNmpZUnnr6QmaxIhTzB9vdTrxCA+peSovvvkcVoR6QXO54VFLYHrpx4myeNEo/B3lZijvj8gRAZHwuZ6DebzoRZqXgqZgdjZ5brzBQz8W8prCzIcjM8mTkzM3oBVRjz3OqZiOvG/tdxOhZBqIl9+T4DUQsCRD2LlzgQAWqG322EpTgC+N5Y7s3UeTIh8YJUs/FX8icveBEnvSGAlBsTac2GAJJ0rhI3OfjEuzcgx7ow0lWxD2fhLcEzwQ4IqOXOyaMWIs6KPaVm3YG9RyikeSS3g9QsfGr2nB/jxBIAnL0y+zgQ7lPWUGrmch5uKb+L1kdYglxQrTjEiyVIT0UqFLk7jVCi9Ezcjx4OEKe0g7C6tari+ljxYyS2p2Dv6R4/8tfJbGciigYMmJTTWbmvfsKZN4BIa0gtEPuRZh04A7VJWL6fCU3ZYJT5NFYoCjmVL0wgW8aF//8MLvnrNZu+Tyc4NwgmSM2GQzpcAy0+ysLtPdApHS/S1hFxjtFBWP1LyX1O5xjWKrkVUbJbBqv3HMnXYrGoc8GbBLwQNjaYAwIsbtMcGWWU0rqDICEquG/S+gMJzZDmK8OzOPv2FBDDXkapDYixF5QoZuMkNoQxspAKxbLRkWfugBnDtfHyINNbapuJwLsg1V+c1KmYc6Xm8F4vUwl/Ri1JW4l8VEQaKSDwIugmhGJGCbh2nOWtCJCaheI0E6UyL/FH0ohD8WwF6p5sxz3qlcfl6ulhtXpYffq6+nW7/Lz9tPwHY6oymxxTVi4fYTYPy8cG87hdb7arDWFwyLbujU9ofny76dAXM9TOwEzn8mHmH8O87bcaNO28VMFPr0LqB1Y9Xd9/N8yF2twUokRSkmw1gofqzVd8RgtolFukptKw+HKenLlHMowbfHjU5SMdIOduF2K7r0/xZDg8uqIVD8/yWY4HkQ7Xl5WhMBwWKqS1pu1JBa2mFLpdqxME4aEcJLWj/zev1KlvXiUTB14pvwsZOfyp4M6jS4byWtgCb0AtEOqZtcV3qLXJczrJdNqEz6jJlUyFdr0Zx32Pj8bbyBWprnrfD/hovH003t41if5/jTct/BnNptHpN65q2qNq/fYf908+1LgXAAA="}, "status": {"code": 200, "message": "OK"}}, "request": {"headers": {"Content-Type": "application/json", "Accept": "application/vnd.github.drax-preview+json", "Connection": "keep-alive", "User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "utf-8", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py", "body": {"string": "", "encoding": "utf-8"}}, "recorded_at": "2017-02-21T11:58:17"}, {"response": {"headers": {"X-GitHub-Request-Id": "F446:7033:B77E58C:E321705:58AC2B4E", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "ETag": "W/\"2e17183210d82012a5e8579790d7dc6e\"", "X-RateLimit-Limit": "5000", "X-OAuth-Scopes": "repo", "X-Served-By": "bae57931a6fe678a3dffe9be8e7819c8", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Reset": "1487680319", "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-XSS-Protection": "1; mode=block", "Content-Encoding": "gzip", "Access-Control-Allow-Origin": "*", "X-GitHub-Media-Type": "github.inertia-preview; format=json", "Date": "Tue, 21 Feb 2017 11:58:07 GMT", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Remaining": "4980", "Content-Security-Policy": "default-src 'none'", "X-Frame-Options": "deny", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-Content-Type-Options": "nosniff", "Transfer-Encoding": "chunked", "X-Accepted-OAuth-Scopes": "repo"}, "url": "https://api.github.com/projects/400435", "body": {"string": "", "encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA52T0WrDMAxFf2X4uZ2bpKUsMMZgn9C97KU4iZZ6OJaxlYwu9N8np9lYW8honxJineurG6kX+GnBb1tvRC52RC7kUiqn72tNu7a4L7GRHhwG+VwYILQv0G0QTZAEgeKJmIlJ2nn8gJKCXC4Wy2zF5SWatrFh+tIzTI4Q47oS+VFrJqxqgI1HL3cjwRUFVnv+ym+2bQrwIs9mIpCiWIsObDThQRHyUS8M1tryiS9xro5djtckSbrOkof1TKhOkbrIafgYsjGsNgBLWAJLQ26t/OGfuseMJWs/ysQWor3J4KJckKemdtSYs9z+/qiTBt7RGPxkjemgL66RvyA7PL5rW98mwmAvkXZxxLidQwxBB7ra0gD1Mj62uooy/Du9h+paWyPGpuLcH/phuAe9tgil1440/jeal4mdwCyGvlZWf6mbxBgOrDFs3bXtDRDD0PEQXk0fqV46rztV7mMsHkrQHed8m+IZzoK0d3ELX3kaYuqaYKuqJu7fuzIBDuNm8o2KuC5dJOv5Ip2nySZJ8tU6z9I35lpX8TZP1Ry+AQSsF9zbBAAA"}, "status": {"code": 200, "message": "OK"}}, "request": {"headers": {"Content-Type": "application/json", "Accept": "application/vnd.github.inertia-preview+json", "Connection": "keep-alive", "User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "utf-8", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/projects/400435", "body": {"string": "", "encoding": "utf-8"}}, "recorded_at": "2017-02-21T11:58:17"}, {"response": {"headers": {"X-GitHub-Request-Id": "F446:7033:B77E5A4:E32176F:58AC2B4F", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Vary": "Accept-Encoding", "X-RateLimit-Limit": "5000", "Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1487680319", "X-Frame-Options": "deny", "Content-Security-Policy": "default-src 'none'", "X-Served-By": "0e17b94a265a427d9cafe798ceea7c02", "X-XSS-Protection": "1; mode=block", "X-OAuth-Scopes": "repo", "Server": "GitHub.com", "X-RateLimit-Remaining": "4979", "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", "Status": "204 No Content", "X-GitHub-Media-Type": "github.inertia-preview; format=json", "Date": "Tue, 21 Feb 2017 11:58:07 GMT", "X-Accepted-OAuth-Scopes": "repo"}, "url": "https://api.github.com/projects/400435", "body": {"string": "", "encoding": null}, "status": {"code": 204, "message": "No Content"}}, "request": {"headers": {"Content-Type": "application/json", "Accept": "application/vnd.github.inertia-preview+json", "Connection": "keep-alive", "User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "utf-8", "Authorization": "token <AUTH_TOKEN>", "Content-Length": "0"}, "method": "DELETE", "uri": "https://api.github.com/projects/400435", "body": {"string": "", "encoding": "utf-8"}}, "recorded_at": "2017-02-21T11:58:17"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"recorded_with": "betamax/0.8.0", "http_interactions": [{"recorded_at": "2017-02-21T11:58:06", "response": {"status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py", "headers": {"X-Frame-Options": "deny", "X-RateLimit-Limit": "5000", "X-GitHub-Request-Id": "F442:7033:B77DEC7:E320EB5:58AC2B44", "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "X-Served-By": "139317cebd6caf9cd03889139437f00b", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-GitHub-Media-Type": "github.drax-preview; format=json", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Accepted-OAuth-Scopes": "repo", "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-RateLimit-Remaining": "4984", "Server": "GitHub.com", "Content-Encoding": "gzip", "Cache-Control": "private, max-age=60, s-maxage=60", "Transfer-Encoding": "chunked", "Content-Security-Policy": "default-src 'none'", "Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1487680319", "X-XSS-Protection": "1; mode=block", "ETag": "W/\"f2528211d57d91b73858bae183c81d71\"", "X-OAuth-Scopes": "repo", "Last-Modified": "Tue, 15 Nov 2016 14:09:50 GMT", "Date": "Tue, 21 Feb 2017 11:57:56 GMT"}, "body": {"string": "", "base64_string": "H4sIAMU4rFgC/+2YwW7jOAxAfyXwddM4bmaaHQODmf2CvexpLoFsM7ZQWRIkOdlUyL8vJcuOHQzSpuphDwWK1JHFJ4YiKVI2oVWSbzd/Zt+2m+0y4aSFJE9qapqu2KzkKVkm+46xXXihad2SA1WdfvySzmaJIweV5DZhoqb8aiq+d+tkm6cn/MuWCTkQQ9SuUwxnNsZInadpP6hXPbfToErBDXCzKkWbdukg/uPwfYPEWgWKQyc4cEWTNJB6ccTp9EqpxrTsSomJyNXkvWBMHJGyu3OhdJQcKZTX76SgpE2FaQCth3POzhBUm/uV8lLW/0MLOo5GYyqo7iYFOVTL+cDZpgqk8MCu0KWi0lDB71dwJu08TNWE0xfyPhpKO4hT7X5hL4XScEBvvF+8F7OpVPRAytPZ61ECPaCx34m8kkeiOUkXoX9PrOS2gBrYkap1IbknTMN5mXg1DE42qoN7gmAe8RWM24Oify0kIyUs9kItFOGVaBfwrwRFW6ffAkcWWiwEX/kYUM9BnVei1hv+hg6O9IrxbiJSD0DQM5yiOE7eus8QSyUGKymEIkaoKPAMZGdf3ToGSBvF9wCXCoWIs6QHuESvdQdvcuvbPM/RY+zwri36dBePHmOGaJzCAaJoI8SmQ0YuMALKJg47MGx48rtN6rjNJj4JFkwUURx8TD3Eproh/RlkdrHaOapjzKAK9tFQxxihRkXut1dT+f0OSDwADW59FHVgpDZAGeF1R+o46ggJx3tNXkDF6hkoPstxo2jRxSe5C+dSNxSxql4wV8XIB1BlOGBRoKUm8td7xMztPwDr/PQa7b7HZs+BMc3JfdIPbz4g6/9ujdAMRDuaY6T2D0lME0wiiYJIizhEaguCBdZqtbINEF8GtKAiI7gnuLNKlQ1WfDEsOzCw6mmJ8ZX63qlZYeXOBKmiNB0hgz98wPE/3X+JfWgU0gOmxJYy0EbwyB0aKVM2F4buafmWbuU2fgayPzTlJSwJY0t0OUNLin6MPWF/YhTAIo8LR8Cfgd1+36UwIJEH28CwaV8ZVyCZOEVnoQnGBbEC7GiqHTHIe1xnTw9Z9pB9/Sf7kq+/5V/Xv9z1gKxenSM73UymbB/Wj37KY77Z5tn2V8jOvd749KZeyf0odwDp5iL48yKW3xYrGbrW3f3ZsOaBv6e1a0QLEsuGJOcYM66LfMHnbFZDlKLjaKb1MjkSg4XqbGioOwZAQ/Suj+ix68SRS8aYDB7pM51+l758GbrFvuG7LNRSpUS4SOqXEhJ4WGuYlwU5LzF5798M2vuXFexJx8yuL7nRbC3RBpTzDFAtSvm7iNwmoaXu1XRec3lmrH/GTpvRErgerTC9wfi8Kvu8Kvu8Kvu/X5VxMEfMHJOEM+1Nwujm/B8QxoEPRxcAAA==", "encoding": "utf-8"}}, "request": {"headers": {"Authorization": "token <AUTH_TOKEN>", "Accept": "application/vnd.github.drax-preview+json", "Connection": "keep-alive", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "Accept-Charset": "utf-8", "User-Agent": "github3.py/1.0.0a4"}, "body": {"string": "", "encoding": "utf-8"}, "uri": "https://api.github.com/repos/sigmavirus24/github3.py", "method": "GET"}}, {"recorded_at": "2017-02-21T11:58:07", "response": {"status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/projects/400435", "headers": {"X-Frame-Options": "deny", "X-RateLimit-Limit": "5000", "X-GitHub-Request-Id": "F442:7033:B77DEE0:E320ED7:58AC2B44", "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "X-Served-By": "8a5c38021a5cd7cef7b8f49a296fee40", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-GitHub-Media-Type": "github.inertia-preview; format=json", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Accepted-OAuth-Scopes": "repo", "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-RateLimit-Remaining": "4983", "Server": "GitHub.com", "Content-Encoding": "gzip", "Cache-Control": "private, max-age=60, s-maxage=60", "Transfer-Encoding": "chunked", "Content-Security-Policy": "default-src 'none'", "Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1487680319", "X-XSS-Protection": "1; mode=block", "ETag": "W/\"2e17183210d82012a5e8579790d7dc6e\"", "X-OAuth-Scopes": "repo", "Date": "Tue, 21 Feb 2017 11:57:56 GMT"}, "body": {"string": "", "base64_string": "H4sIAMU4rFgC/52T0W6DIBSGX2Xh2paqbcxMlr3EdrMbg0qVBYHA0cYZ330H6pq1S9bYKw2c7+P3yJmIPilui95KkpMWwLicUmbEthHQ9uW20h213GhHnWg6Ngjbu2RPz7vp1owkIv/CxupPXoGj+91unx6wvNKy75Qr1mB0gRAXNcnPixFRrOPoAO7gaSGwotT1iKv4pvqu5JbkaUQcMPC12nDlQ1jOQOPWRKRuhMIdW+kNKyUHrZZj4jjJ0vg5iwgbGLA/bQqLLl1y946jQgFXED6hpz/86/CSorKxi8a7yb3GeZ2j16Fa6ORNiN//6ar2qKXUJ3QU646hF/AiEap5TILgRDW0/oZhyeybIBysjhSgKTyweV6Dv9NaXq8VLRiG8td+nsLdDr6+dJUVBoRWq+NdwSjTtmFKfLGHZAh7Rxi6tWyAEOYDXsLV9JmacPbEwKpxDikqLgbs82PGGxyFMBo/he9Y6rsugBes7vz8HZl0fF4mExEGWJfs4myzSzZJ/BbH+SHL0+TDD46p79TM3+ai9EfaBAAA", "encoding": "utf-8"}}, "request": {"headers": {"Authorization": "token <AUTH_TOKEN>", "Accept": "application/vnd.github.inertia-preview+json", "Connection": "keep-alive", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "Accept-Charset": "utf-8", "User-Agent": "github3.py/1.0.0a4"}, "body": {"string": "", "encoding": "utf-8"}, "uri": "https://api.github.com/projects/400435", "method": "GET"}}, {"recorded_at": "2017-02-21T11:58:07", "response": {"status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/projects/400435", "headers": {"X-Frame-Options": "deny", "X-RateLimit-Limit": "5000", "X-GitHub-Request-Id": "F442:7033:B77DEF3:E320EF7:58AC2B44", "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "X-Served-By": "46808ddc41c302090177e58148908b23", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-GitHub-Media-Type": "github.inertia-preview; format=json", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Accepted-OAuth-Scopes": "repo", "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-RateLimit-Remaining": "4982", "Server": "GitHub.com", "Content-Encoding": "gzip", "Cache-Control": "private, max-age=60, s-maxage=60", "Transfer-Encoding": "chunked", "Content-Security-Policy": "default-src 'none'", "Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1487680319", "X-XSS-Protection": "1; mode=block", "ETag": "W/\"2e17183210d82012a5e8579790d7dc6e\"", "X-OAuth-Scopes": "repo", "Date": "Tue, 21 Feb 2017 11:57:56 GMT"}, "body": {"string": "", "base64_string": "H4sIAMU4rFgC/52T0W6DIBSGX2Xh2paqbcxMlr3EdrMbg0qVBYHA0cYZ330H6pq1S9bYKw2c7+P3yJmIPilui95KkpMWwLicUmbEthHQ9uW20h213GhHnWg6Ngjbu2RPz7vp1owkIv/CxupPXoGj+91unx6wvNKy75Qr1mB0gRAXNcnPixFRrOPoAO7gaSGwotT1iKv4pvqu5JbkaUQcMPC12nDlQ1jOQOPWRKRuhMIdW+kNKyUHrZZj4jjJ0vg5iwgbGLA/bQqLLl1y946jQgFXED6hpz/86/CSorKxi8a7yb3GeZ2j16Fa6ORNiN//6ar2qKXUJ3QU646hF/AiEap5TILgRDW0/oZhyeybIBysjhSgKTyweV6Dv9NaXq8VLRiG8td+nsLdDr6+dJUVBoRWq+NdwSjTtmFKfLGHZAh7Rxi6tWyAEOYDXsLV9JmacPbEwKpxDikqLgbs82PGGxyFMBo/he9Y6rsugBes7vz8HZl0fF4mExEGWJfs4myzSzZJ/BbH+SHL0+TDD46p79TM3+ai9EfaBAAA", "encoding": "utf-8"}}, "request": {"headers": {"Authorization": "token <AUTH_TOKEN>", "Content-Length": "36", "Accept": "application/vnd.github.inertia-preview+json", "Connection": "keep-alive", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "Accept-Charset": "utf-8", "User-Agent": "github3.py/1.0.0a4"}, "body": {"string": "{\"body\": \"\", \"name\": \"test project\"}", "encoding": "utf-8"}, "uri": "https://api.github.com/projects/400435", "method": "PATCH"}}]}

tests/integration/test_projects.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
"""Integration tests for methods implemented on Project."""
3+
4+
from .helper import IntegrationHelper
5+
6+
7+
class TestProject(IntegrationHelper):
8+
"""Project integration tests."""
9+
10+
def test_delete(self):
11+
"""Test the ability to delete a Project."""
12+
self.token_login()
13+
cassette_name = self.cassette_name('delete')
14+
with self.recorder.use_cassette(cassette_name):
15+
repository = self.gh.repository('sigmavirus24', 'github3.py')
16+
project = repository.project(400435)
17+
assert project.delete()
18+
19+
def test_update(self):
20+
"""Show that one can update a Project."""
21+
self.token_login()
22+
cassette_name = self.cassette_name('update')
23+
with self.recorder.use_cassette(cassette_name):
24+
repository = self.gh.repository('sigmavirus24', 'github3.py')
25+
project = repository.project(400435)
26+
assert project.update(project.name, project.body) is True

tests/unit/json/project_example

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"owner_url": "https://api.github.com/repos/api-playground/projects-test",
3+
"url": "https://api.github.com/projects/1002604",
4+
"id": 1002604,
5+
"name": "Projects Documentation",
6+
"body": "Developer documentation project for the developer site.",
7+
"number": 1,
8+
"creator": {
9+
"login": "octocat",
10+
"id": 1,
11+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/octocat",
14+
"html_url": "https://github.com/octocat",
15+
"followers_url": "https://api.github.com/users/octocat/followers",
16+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
20+
"organizations_url": "https://api.github.com/users/octocat/orgs",
21+
"repos_url": "https://api.github.com/users/octocat/repos",
22+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/octocat/received_events",
24+
"type": "User",
25+
"site_admin": false
26+
},
27+
"created_at": "2011-04-10T20:09:31Z",
28+
"updated_at": "2014-03-03T18:58:10Z"
29+
}

0 commit comments

Comments
 (0)
0