Commit c05d8be2 authored by Meet Mangukiya's avatar Meet Mangukiya

test_github_repository: Add tests for GitHubRepository

Adds to #34
parent 20aec4bd
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [GitMate]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test
response:
body:
string: !!binary |
H4sIAAAAAAAAA6WY3XKjOBCFX2WK27UtmIwzWaq2Zh9i9mZvXDLIoA0gVhJ2JVTefU9LYLAnhb3W
TYrI6k9HP93qVh/JPEq//b7dvnzfJquo4bWI0sgKY6NVdOiqajc0FdLW3Io1/bTujNBs6KROjdBR
2keVKmQD4196gkSjJM/PL0n8FK8ifuSW612nK3QvrW1NyphvNPEG9mW3pyEy1VjR2E2matax0f7H
8Y8nIAs9YIgdoeEK18qB5M2BM+wzaaWtqyspXoGz+8zioKpKncC7nsFdQ7KzOa2wQ8mmCEHBvGfK
lgJLiml+0OJIYx+U50x7TNzYncwJZrBZWuSPSRyMIZDOyUfPtGiVo3Z7k2nZWqmaB6VeIIBUuuCN
fOcBSCAMSCTyQVHOFAhxxNF9kOFte9ZqeeTZGy2XFpmQR+xCCPcKAqx9a8nh/8K5oT2RVux4XpMf
H3hlxMcqchosOrmGFfz1f/nLGCZycd5tjMe/UPT4QmuFYQ9Kv575i27sFvdXpxwHIdCNJV8iwDVh
D0Gv4i0EQ+Y9w9/BgTJ4Od8rza26FTQW5V1wejb/l46IFbwOke3swSmVClpFZw+ONKYTd53XxVk7
jGGjTzRdvfdB7h5PWCR7AJRyY2TRCBGyemdGz8YovNe8ycog6ojomf9y+8yLEKFkDsq+UvsQDG5G
5hg9MyX3l47dBWojKCEumFocQoUS4sy0OmynnUhinIm45Cw2PUTliGD9sJoVb4qOF0HQMwP7TRdx
wd9vpi2LHjNBQKT0TMt9FxzVJgzp9HkBfDxoOSfKxHS5xnIaszz7Wcri5l/X8tYVvwgcCBenPZxK
5/OaTP/fzkduiiVEz6YQ7EP8AA9Y2SHGjyrnQwxFQMhhGBGs/63ltqRYhZFarkWA5IHA+j1HnrTZ
bPpScJcv10KHua0HgMR1ViLpC1DZjwikNqjfXP59IJE58vFK8TxkXc8M8PwOBij1gPnOtyg/Q+Q5
+zmwlhWyTtUExdQJMkc3ysqDzO4pPRad7ILT/zCyycSKV9UKp9XKTOL8otyjDURGKYKWxwMwCdT8
vsKoBI5yyIpr4RE985VjLtpKvYUGnhmFPFcLlCP5jlvUEV/j5HkdJ+vk6Wf8Pd0+p8n2b/Tp2vxm
n7Yz5QUmSdbxy88kTuM4ffpKGATS4UDjC08US+8CrgShFwfYGVNOdn9OVik+P3lEGayyCifzyoHu
HvF4fa/dtITOUtWiRYoRpQ1chcq/d3zjGWiWK2Sqa7DSeLU5cYtkFrfy1DTmFyOg5Gbn/ThKre6o
WkRLq9U/IrNm3jaFjlnHk3yVF4aU/pwLQ1/cDYNDZC21VsMrktevWtEM448it998eQkMTGYdopR+
GufkJpiLA+8qu/OZNk5XzY11dXErdI150UsFvXQNFbKfIZ2jUTRFHP+Nwhleq04782/HcRxcSB+7
+V9cE3RSEnH5ixZ0p1zaNMKeUJ2O86JNmiVK45Z8/AcXL+mO0RMAAA==
headers:
Access-Control-Allow-Origin: ['*']
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']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Encoding: [gzip]
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 07 Jun 2017 07:43:50 GMT']
ETag: [W/"7996f529f38d3b12dbebe7de5134b7f4"]
Last-Modified: ['Wed, 13 Jan 2016 07:56:15 GMT']
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: [repo]
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['818C:13F62:84062B7:ACA0213:5937AEB6']
X-OAuth-Scopes: ['admin:org, admin:org_hook, admin:public_key, admin:repo_hook,
delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4823']
X-RateLimit-Reset: ['1496823149']
X-Runtime-rack: ['0.052518']
X-Served-By: [77fbfb53269bbb85f82f23584d59f7c1]
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1
interactions:
- request:
body: '{"body": "body", "title": "title"}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['34']
Content-Type: [application/json]
User-Agent: [GitMate]
method: POST
uri: https://api.github.com/repos/gitmate-test-user/test/issues
response:
body: {string: '{"url":"https://api.github.com/repos/gitmate-test-user/test/issues/60","repository_url":"https://api.github.com/repos/gitmate-test-user/test","labels_url":"https://api.github.com/repos/gitmate-test-user/test/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/gitmate-test-user/test/issues/60/comments","events_url":"https://api.github.com/repos/gitmate-test-user/test/issues/60/events","html_url":"https://github.com/gitmate-test-user/test/issues/60","id":234120582,"number":60,"title":"title","user":{"login":"gitmate-test-user","id":16681030,"avatar_url":"https://avatars0.githubusercontent.com/u/16681030?v=3","gravatar_id":"","url":"https://api.github.com/users/gitmate-test-user","html_url":"https://github.com/gitmate-test-user","followers_url":"https://api.github.com/users/gitmate-test-user/followers","following_url":"https://api.github.com/users/gitmate-test-user/following{/other_user}","gists_url":"https://api.github.com/users/gitmate-test-user/gists{/gist_id}","starred_url":"https://api.github.com/users/gitmate-test-user/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitmate-test-user/subscriptions","organizations_url":"https://api.github.com/users/gitmate-test-user/orgs","repos_url":"https://api.github.com/users/gitmate-test-user/repos","events_url":"https://api.github.com/users/gitmate-test-user/events{/privacy}","received_events_url":"https://api.github.com/users/gitmate-test-user/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-07T07:46:09Z","updated_at":"2017-06-07T07:46:09Z","closed_at":null,"body":"body","closed_by":null}'}
headers:
Access-Control-Allow-Origin: ['*']
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']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Length: ['1727']
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 07 Jun 2017 07:46:09 GMT']
ETag: ['"f1ac493ad6de57274a98022aaf040b07"']
Location: ['https://api.github.com/repos/gitmate-test-user/test/issues/60']
Server: [GitHub.com]
Status: [201 Created]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: ['']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['81B4:13F61:79C4AD9:9F46528:5937AF41']
X-OAuth-Scopes: ['admin:org, admin:org_hook, admin:public_key, admin:repo_hook,
delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4811']
X-RateLimit-Reset: ['1496823149']
X-Runtime-rack: ['0.130039']
X-Served-By: [6694d697f15dfc31f0ffaf8cdb1d5a86]
X-XSS-Protection: [1; mode=block]
status: {code: 201, message: Created}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [GitMate]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test/issues/60
response:
body:
string: !!binary |
H4sIAAAAAAAAA62U0W7bMAxF/0XPSaUkndMZKPoT28uGIZBt1hEmS4Yku8iM/Puu5CRds6XtnD45
ocgjipfkwDqnWc62IbQ+51y26qZWYdsVN6VtuKPWeg5DIwPNA/kw7zw5Hn9x5X1HnmeCzVhyVMG6
3WYyEBgtC9J+OuI5Jz6iBm5kQ3ug8ZyGTPgY+BEGLvUfRh1RYG5Do8+K8Ico75BDVSxfrm4XS/Hp
bjljpmsKcizPxIwFFTRB8fE7Y1FPlg9M21oZ2P+iI5+IW2TZ3UKsQJC9DNKdi5SMXhy6J1JLawJq
kxqp48f4h/5+BWTtDpjIZjC82jYR948+/P9SIeLRam2fwDt/wcvWv3AlP4WfUMrU16AQPnAbtoSS
4pmxV2vl32rUS+ml0AEj68NGVRHmoYujalqKh2Ak+GSQ25A2QqJ2hS+daoOyZmIlXyCAtK6WRv2S
VyCB8CClbTTtwSkUiPeM9SUNxtiBt071stzFcjkqSfVQ4RruGQTYsGvjLH+NMwxNVKCNrJo4x49S
e9ofNyrLv/9InRCiu23JwF3b8idh+pIrxtp7VRuCg+m0fv7vx+BGaSx9a07npx2YYyeUjsCuNjKA
vxSL9Vxkc7H+Itb5bZaLz99wX9dWb/qU2voDZsyisNUOyPTBNeNxAVM83v8Gtkd4Tb8GAAA=
headers:
Access-Control-Allow-Origin: ['*']
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']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Encoding: [gzip]
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 07 Jun 2017 07:46:10 GMT']
ETag: [W/"f1ac493ad6de57274a98022aaf040b07"]
Last-Modified: ['Wed, 07 Jun 2017 07:46:09 GMT']
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: ['public_repo, repo']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['C0F2:13F61:79C4BA0:9F4660B:5937AF42']
X-OAuth-Scopes: ['admin:org, admin:org_hook, admin:public_key, admin:repo_hook,
delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4810']
X-RateLimit-Reset: ['1496823149']
X-Runtime-rack: ['0.050971']
X-Served-By: [eef8b8685a106934dcbb4b7c59fba0bf]
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1
This diff is collapsed.
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [GitMate]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test/issues/1
response:
body:
string: !!binary |
H4sIAAAAAAAAA+2X247aMBCGX2Xra1gnpIVVpKrqO7Q3PQg5yWyw6tiR7bCiEe/e3ybQQpfdFvZi
L3KHzD+fx56DJz3rrGI5W3nfupxz0crbWvpVV9yWpuGWWuM4FhrhaerJ+WnnyPLwi0vnOnI8ZRMW
ddIbu1lezANGiYKUuxxxcInvSD3XoqEtyDhMQ9q/CHvPApbWLwXdkYBc+Uad3MAfAXk+FLJieTqb
Z/NscZdMmO6agiyWJsxLrwixDsG7icHDdiGcLO+ZMrXU+POvDaCJyPn8Lk0yEMVaeGFPgxQXXTIk
T6CWRnvcTsyjju/tP6zfZ0DWdsAENgt+PJWGAfdIGv7/bcHi3ihlHsA7PcFx5p/Zkh/MDyip62tQ
MO+58SvCleKYIVlr6Z7L1HPuRdMeFev8UlYB5hAXS9VlLg7GcPBBw7c+NoRI7QpXWtl6afSFN3mE
ANLYWmj5U1yBBMKBFLvRZQeOpkD8S2Gfi8HOtuetlWtRbsJ1WSpJrhGFa7gnEGD9pg0F/TnUMGIi
PS1F1YQ6vhfK0XbfUVn+9XvMBB/kpiUNuTLlD0L1RSnK2jlZa4JgbAanz+C5SI/NYGwGw6R0LkVe
UzPYl7hDPxiLfCzyR0YqPr74T3wOvf4ixzPfSIUB32i85LpT6ve3D8sxvZeWMAVUS+ExCcySdD5N
0mmafUoW+bt5Psu+YDLo2upIs5gmkC2CJp3lb5OgKZVxA2a3S2GqDZAfb7Qs6aaiw3j45luYNgZ9
AU3Qb38BG/EBC3kOAAA=
headers:
Access-Control-Allow-Origin: ['*']
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']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Encoding: [gzip]
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 07 Jun 2017 07:46:14 GMT']
ETag: [W/"7ff42e8f20e5928f38ca9bb1b18a391b"]
Last-Modified: ['Wed, 07 Jun 2017 07:12:40 GMT']
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: ['public_repo, repo']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['81B8:13F62:840AE76:ACA62AF:5937AF44']
X-OAuth-Scopes: ['admin:org, admin:org_hook, admin:public_key, admin:repo_hook,
delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4809']
X-RateLimit-Reset: ['1496823149']
X-Runtime-rack: ['0.099462']
X-Served-By: [a474937f3b2fa272558fa6dc951018ad]
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [GitMate]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test/labels
response:
body:
string: !!binary |
H4sIAAAAAAAAA63OwQqDMAzG8XfJuRplwrSvMnaIGmehXUubnsbefe1JdhoDyeXPdwi/2wvMCvrS
D90wTmOnIEcLGnaRkDQiBdM+jOx5bhfvMHLwCcvgSLgRTtLkxBFroaWZbUICBU9yXL7UXLz1sTSv
9cqw8kbZCuiNbOK3+hb0JwjmQ1DzP8F1OkGwHIKavwT3D6H3vfiHAQAA
headers:
Access-Control-Allow-Origin: ['*']
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']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Encoding: [gzip]
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 07 Jun 2017 07:43:56 GMT']
ETag: [W/"c9f82d5039c119817b46f1296032238b"]
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: [repo]
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['C0CC:13F61:79C091F:9F41070:5937AEB8']
X-OAuth-Scopes: ['admin:org, admin:org_hook, admin:public_key, admin:repo_hook,
delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4822']
X-RateLimit-Reset: ['1496823149']
X-Runtime-rack: ['0.020193']
X-Served-By: [4537b68c46a1b65b106078b0a2578ee2]
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1
This diff is collapsed.
This diff is collapsed.
import unittest
import os
import vcr
from IGitt.GitHub.GitHubRepository import GitHubRepository
from IGitt import ElementAlreadyExistsError, ElementDoesntExistError
my_vcr = vcr.VCR(match_on=['method', 'scheme', 'host', 'port', 'path'],
filter_query_parameters=['access_token'],
filter_post_data_parameters=['access_token'])
class TestGitHubRepository(unittest.TestCase):
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo.yaml')
def setUp(self):
self.repo = GitHubRepository(os.environ.get('GITHUB_TEST_TOKEN', ''),
'gitmate-test-user/test')
def test_hoster(self):
self.assertEqual(self.repo.hoster, 'github')
def test_full_name(self):
self.assertEqual(self.repo.full_name, 'gitmate-test-user/test')
def test_clone_url(self):
self.assertEqual(self.repo.clone_url,
'https://{}@github.com/gitmate-test-user/test.git'.format(
os.environ.get('GITHUB_TEST_TOKEN', ''))
)
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_get_labels.yaml')
def test_get_labels(self):
self.assertEqual(sorted(self.repo.get_labels()), ['a', 'b', 'c'])
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_create_label.yaml')
def test_labels(self):
with self.assertRaises(ElementAlreadyExistsError):
self.repo.create_label('a', '000000')
with self.assertRaises(ElementDoesntExistError):
self.repo.delete_label('f')
self.repo.create_label('bug', '000000')
self.assertEqual(sorted(self.repo.get_labels()),
['a', 'b', 'bug', 'c'])
self.repo.delete_label('bug')
self.assertEqual(sorted(self.repo.get_labels()), ['a', 'b', 'c'])
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_get_issue.yaml')
def test_get_issue(self):
self.assertEqual(self.repo.get_issue(1).title, 'test issue')
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_merge_requests.yaml')
def test_merge_requests(self):
self.assertEqual(len(self.repo.merge_requests), 3)
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_create_issue.yaml')
def test_create_issue(self):
self.assertEqual(self.repo.create_issue(
'title', 'body').title, 'title')
@my_vcr.use_cassette('tests/GitHub/cassettes/github_repo_hooks.yaml')
def test_hooks(self):
self.repo.register_hook('http://some.url/in/the/world', '...')
self.assertIn('http://some.url/in/the/world', self.repo.hooks)
self.repo.register_hook('http://some.url/in/the/world')
self.repo.delete_hook('http://some.url/in/the/world')
self.assertNotIn('http://some.url/in/the/world', self.repo.hooks)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment