From f296ac259f5340f87b9e1eefc881d923e14ee7fc Mon Sep 17 00:00:00 2001 From: Matt Chung Date: Wed, 20 Jan 2016 11:09:06 +0000 Subject: [PATCH] Migrated some test cases to tests/{integration,unit} Removed test_milestone from test_repos_repo since unit and integration tests already exist. Replaced repos_repo_example JSON since permissions element was missing Migrated test_parent, test_permission to tests/unit Migrated test_pull_request to tests/{unit/integration} Migrated test_readme to tests/{unit/integration} Migrated test_ref to tests/{unit/integration} --- tests/cassettes/Repository_pull_request.json | 1 + tests/cassettes/Repository_readme.json | 1 + tests/cassettes/Repository_ref.json | 1 + tests/integration/test_repos_repo.py | 27 ++ tests/test_repos.py | 41 --- tests/unit/json/repos_repo_example | 355 ++++++++++++++----- tests/unit/test_repos_repo.py | 45 +++ 7 files changed, 338 insertions(+), 133 deletions(-) create mode 100644 tests/cassettes/Repository_pull_request.json create mode 100644 tests/cassettes/Repository_readme.json create mode 100644 tests/cassettes/Repository_ref.json diff --git a/tests/cassettes/Repository_pull_request.json b/tests/cassettes/Repository_pull_request.json new file mode 100644 index 000000000..8a0589aa0 --- /dev/null +++ b/tests/cassettes/Repository_pull_request.json @@ -0,0 +1 @@ +{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA62YzW7rNhCFX8XQto5p2fFNIqC47art7i7STTcGJdESEUkUSMqGI+Tde0jq1xe1nbBAYMQy5+PhcIaaYRvwNIi2T+H6KQyXQUVLFkRBxnXexNtVfQ6WwaEpin33g+JZSY9cNmrzSGajxKliMojaoBAZr8CYDgXFTLN5XD9v18uAHqmmct/IAuNyrWsVEeIeqpWjNorJRFSaVXqViJI0xBl/P/66BS2THcNgA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o6hT4/PuOyZFASJaCrsx+PuZRmcqEbtilfv9GFfSAxNn5maqr1L0yDSsjFdJZ6Mx8Dk4Ym/8bH3xCgjWfVmrovrpgu/7XBucilFd0NUIW1xA1CzqpttEAaxrn+LrNFkCJYyWUm3sJQdaFPovaunsZIUjUAhaiylYvqETrAnW9y0Cum0bZ4+/gUo0NPZMRMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"5399018257b7266365dfec2a919c7bcf\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "59", "x-served-by": "bae57931a6fe678a3dffe9be8e7819c8", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:12179:293AF82:569F6D68", "access-control-allow-credentials": "true", "last-modified": "Wed, 20 Jan 2016 02:52:59 GMT", "date": "Wed, 20 Jan 2016 11:20:08 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-20T11:20:08"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/pulls/546"}, "response": {"body": {"string": "", "base64_string": "H4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uhuLGGxCBN1xFvn+TlK38b0LEElP7xP8vNsOf9OgAA", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"916cd51cf68004e56e7820d4732dd5c3\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "58", "x-served-by": "318e55760cf7cdb40e61175a4d36cd32", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:12179:293AF91:569F6D68", "access-control-allow-credentials": "true", "last-modified": "Wed, 20 Jan 2016 06:50:19 GMT", "date": "Wed, 20 Jan 2016 11:20:09 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/pulls/546"}, "recorded_at": "2016-01-20T11:20:09"}], "recorded_with": "betamax/0.5.0"} \ No newline at end of file diff --git a/tests/cassettes/Repository_readme.json b/tests/cassettes/Repository_readme.json new file mode 100644 index 000000000..e5e8708c2 --- /dev/null +++ b/tests/cassettes/Repository_readme.json @@ -0,0 +1 @@ +{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAA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OEI45Ra5tdRMHJ/DzkCFgGrgFcp1IwhLSX1yVzjJa4TjORDI1IuqcaDcRmHW4e1tuHcPsavkS752i3/Qcraep0Nubbwzp82Kxf15toh78XM6ZuVD7B2CHhy2uI33fdEJyAXQjiP1wx4BPXGj/195OWwtwagK1UPhr+NppF/3H/0ZklBWLpIujvn/N4+Vq6bQqpuShZjTKhu0kZVrmtzyt4OkX7lYpErdADE7My/o6hT4/PuOyZFASJaCrsx+PuZRmcqEbtilfv9GFfSAxNn5maqr1L0yDSsjFdJZ6Mx8Dk4Ym/8bH3xCgjWfVmrovrpgu/7XBucilFd0NUIW1xA1CzqpttEAaxrn+LrNFkCJYyWUm3sJQdaFPovaunsZIUjUAhaiylYvqETrAnW9y0Cum0bZ4+/gUo0NPZMRMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"5399018257b7266365dfec2a919c7bcf\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "57", "x-served-by": "bd82876e9bf04990f289ba22f246ee9b", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:B793:12BCE371:569F6EFB", "access-control-allow-credentials": "true", "last-modified": "Wed, 20 Jan 2016 02:52:59 GMT", "date": "Wed, 20 Jan 2016 11:26:51 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-20T11:26:51"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/readme"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA7VXa2+jSBb9L/m6ozZg02u31FoFYgMOdsbY5lGyNOLhFNhFgczDwaP573MKO4+OtlfqkfYDUUJu3bqPc869/HnHw3x/9+3Omd4/LKZfTlV999tdGdbp53dVGuKVFKqjsRrLo3GoPI+kJBqFkbIP/x2P9spYjsbDoRSNnuUJnFTZBY7lyXj0211zYjic1nVZfRsMwjL7QrM6baIvcZEPTvuyqAZVRvOwzU5NpYwG1/8Ov5TdIC54ved1NXiP8D+n/fP3ZN/uWVHiorTO2R8/3vDB+8/8RqyIBjcnH3zDHw5/cvdLAeP4QDivBr9QrKQ4c1aEyaeLT+H5Vqmm2p9upeiL9rO0/mtGdVeKHj9nbI/8bm7wws5GNPTklCjbr0+0oJZ+T0PTkWJz8dXuJl3gxw1RmBSabmbnyzZaTy6hl9SBT8odj7l7WRxW7avFolPP+/XkSHzCImNythVWB17C4m7Cw4dFjXc8gk2Ux487rudJmRipHBwWTWweaegvaLDWDpEin+PcLYinXkJ4snUtDYZOmeRutV9rvfcdF/6Jt6KBpx4twx0l5jyNhvNj6KlpnDNheUmMWRYZW6rzBJloZ+JbNPDn7Y4n4pTpFGStmaHvWIln0ZWrzS09VRbdsdFpuSHelq6nbONOJ2tvrXbxcEVJPul23DJmzX59nwV8zgKvLpFPZhnLArFw4i/E6XnEl1LgvVSB75SRMnq011Itnh1//U2nhaj5o6i5pa9obLCzZbAmHjppZJypvRZ12NKP1d3x/ap4dAwXuatHPIfQcy96dvX96tmGjb3WOuLPZOIvpVgeU8uYq4h8WrMoV1liULrN3TIxe0sZFZOIJ58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EWBzrjjMA3ZucxWCKmz9OhQCfEBPrIUOeCymjQzgJseVNOMdeEtqwUMQWJMbsEypg+mp917Yh6Y1fgDub2im6G0FVv0sTnd2y8T0EgpWedk7sM2eSIWDATjOy5fFVk4+OmwMBQcAwMjSkmK91iXgZK/Tv2g44AA0l35TimsWqZ1wnY39/dY9ZqmILRcEvBIxVzC2q8Fdydk0xTxXsCrQFKT7h7A807hFLPlhz7xhBKAlXET2gGpqsHVcAGcJ0bM8kye/W9iD6IDQHIgeaxqs/mHrsVsrjNsX7jYfe4J0O+VSh4JLYrsMea9V6wYUE1vZdL1ImNSEW2S3E39pPQm1L0Mw29c3nbYdJbp0T0iGspCc2FOkuh3ufcT2pxN0NXFm08dDlReq3u/xbT6ab8VKhj6AW0118zKWOF9jNgxzEFDpHpHlEZkSN2M7GTiYrNpGAttLPn8w8z7ZXRwBo0RWw26FT73qnbPPfdK84V9WLDhigJqvruCWjBfNTp9+87jvV1z+MiyTjF/hqF1f7rCO/+YBk/Vnff/ryr9uz5//epgd3+nzr/R58F4tPmw4Xw8frR9LP9/2efNX/99Td1zv/K6w0AAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"50d78e78546f916610b8773f838d20a4\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "56", "x-served-by": "a7f8a126c9ed3f1c4715a34c0ddc7290", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:B793:12BCE3AC:569F6EFB", "access-control-allow-credentials": "true", "last-modified": "Tue, 19 Jan 2016 12:55:59 GMT", "date": "Wed, 20 Jan 2016 11:26:51 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/readme"}, "recorded_at": "2016-01-20T11:26:51"}], "recorded_with": "betamax/0.5.0"} \ No newline at end of file diff --git a/tests/cassettes/Repository_ref.json b/tests/cassettes/Repository_ref.json new file mode 100644 index 000000000..5fa0a1767 --- /dev/null +++ b/tests/cassettes/Repository_ref.json @@ -0,0 +1 @@ +{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA62YzW7rNhCFX8XQto5p2fFNIqC47art7i7STTcGJdESEUkUSMqGI+Tde0jq1xe1nbBAYMQy5+PhcIaaYRvwNIi2T+H6KQyXQUVLFkRBxnXexNtVfQ6WwaEpin33g+JZSY9cNmrzSGajxKliMojaoBAZr8CYDgXFTLN5XD9v18uAHqmmct/IAuNyrWsVEeIeqpWjNorJRFSaVXqViJI0xBl/P/66BS2THcNgAzy4YNW84zhjwBS5EJTrsriQ4Ka2JheDD6IoxAmUS9G3JiKDpfGkpfAq+yIFli0ROmfwHZb0YRzBlf68KGvVYgOV3vPUcBQ2RLL008I6O8gy+//REslqYYFNrBLJa81F9XmBM2vQhMxoxd/p12iwVoAYaZ+XYq1gzY6Ixc+bO7OW1JIfaXI2rpEsYfwIZ38ReWEPoj7XJm3/RlAY13PN9jQtTRoeaKHYxzKw02sMsg+WyLp7o3+e5ikbdhUT/jjrXFSLgseSyvPiIOSCI2flgSaI1cUJx8gC4br4g+s/m3jx+4+/jiZ7Me5tUHI1c63zZ8k4l2NIN/bkKgLpCQAkvbGzF8fYtwSfXT4lSHUaC0m1uHVoXBc4A7Vk+tXEkma09BJuAQDlQvh50gIA4ko17K7Qvr5wy1Gkz5+qKWN35N2TNdfRjgCtVOGcrxjz8uAAaUl/KiMdqiT3w/aMlrj/7G7TzEuqsQcmLkTsxcGLklhIS1RO3XtI733VGaphzKCSHbylGsYA1dJzv61MAxmQeAlqbL2Xzp5B2s6jBa2yhmZ+1AGCXTev6oy+3yxirufOSAHSVGiSx43/ITdyjFJXOyDf/Vw6YkaoLUiulzk3HDApbKwLypLfqguuEzvELOz/B6yJ00u0+X67jLkt1zBaMp7J7tDv6D7e7U79Xud0jq4d8AqJnkHaX2qqc3NyYaqaSuYjukOQNqYotlarVZszasvqkknPDHYEoKhMclSNPjrbnoGqp6TaVusHIzNF9V4Imnr5doAA6LbRR6sjTPe/Rh/qJdACpsSSF0xpUfmdsSNlyq6E5gee3NOxXE+3Gaj9rniVsCUtiiWiVvOEI45Ra5tdRMHJ/DzkCFgGrgFcp1IwhLSX1yVzjJa4TjORDI1IuqcaDcRmHW4e1tuHcPsavkS752i3/Qcraep0Nubbwzp82Kxf15toh78XM6ZuVD7B2CHhy2uI33fdEJyAXQjiP1wx4BPXGj/195OWwtwagK1UPhr+NppF/3H/0ZklBWLpIujvn/N4+Vq6bQqpuShZjTKhu0kZVrmtzyt4OkX7lYpErdADE7My/o6hT4/PuOyZFASJaCrsx+PuZRmcqEbtilfv9GFfSAxNn5maqr1L0yDSsjFdJZ6Mx8Dk4Ym/8bH3xCgjWfVmrovrpgu/7XBucilFd0NUIW1xA1CzqpttEAaxrn+LrNFkCJYyWUm3sJQdaFPovaunsZIUjUAhaiylYvqETrAnW9y0Cum0bZ4+/gUo0NPZMRMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"5399018257b7266365dfec2a919c7bcf\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "48", "x-served-by": "dc1ce2bfb41810a06c705e83b388572d", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:14B5A:CADCD15:569F72BA", "access-control-allow-credentials": "true", "last-modified": "Wed, 20 Jan 2016 02:52:59 GMT", "date": "Wed, 20 Jan 2016 11:42:51 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-20T11:42:51"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/git/refs/tags/0.9.3"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA6WPTQ6DIBCF78K6YaSgFG8DOlWaGggDJsZ492K766pJN5OX+Xnvm50lvLP+rATZTgQNN1yyCyvpWftzzpF6ABs9n3yei+NDWCBhDATkp8WuPhW6KvhMJY/bKevGt2FwDxwy63dGs63Wo2w7bIVWjdWtbkaNUqnBKHvrHKLsUAkhJJrKkreI9aLy/Q/2fvLn7ON4AfFahrgiAQAA", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"c6cd395269815a18c950ac0a9d297cdd\"", "cache-control": "public, max-age=60, s-maxage=60", "x-poll-interval": "300", "status": "200 OK", "x-ratelimit-remaining": "47", "x-served-by": "8dd185e423974a7e13abbbe6e060031e", "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", "transfer-encoding": "chunked", "x-github-request-id": "D54E579D:14B5A:CADCD54:569F72BB", "access-control-allow-credentials": "true", "last-modified": "Wed, 20 Jan 2016 02:52:59 GMT", "date": "Wed, 20 Jan 2016 11:42:51 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453292408"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/git/refs/tags/0.9.3"}, "recorded_at": "2016-01-20T11:42:51"}], "recorded_with": "betamax/0.5.0"} \ No newline at end of file diff --git a/tests/integration/test_repos_repo.py b/tests/integration/test_repos_repo.py index 177823115..52d3daaaf 100644 --- a/tests/integration/test_repos_repo.py +++ b/tests/integration/test_repos_repo.py @@ -785,6 +785,15 @@ def test_notifications(self): for notification in notifications: assert isinstance(notification, github3.notifications.Thread) + def test_pull_request(self): + """Test that a user can retrieve a pull request from a repo.""" + cassette_name = self.cassette_name('pull_request') + with self.recorder.use_cassette(cassette_name): + repository = self.gh.repository('sigmavirus24', 'github3.py') + pull_request = repository.pull_request(546) + + assert isinstance(pull_request, github3.pulls.PullRequest) + def test_pull_requests(self): """Test that a user can retrieve the pull requests from a repo.""" cassette_name = self.cassette_name('pull_requests') @@ -811,6 +820,24 @@ def test_pull_requests_accepts_sort_and_direction(self): assert last_pr.updated_at < pr.updated_at last_pr = pr + def test_readme(self): + """Test the ability to retrieve the README.""" + cassette_name = self.cassette_name('readme') + with self.recorder.use_cassette(cassette_name): + repository = self.gh.repository('sigmavirus24', 'github3.py') + readme = repository.readme() + + assert isinstance(readme, github3.repos.contents.Contents) + + def test_ref(self): + """Test the ability to retrieve a ref.""" + cassette_name = self.cassette_name('ref') + with self.recorder.use_cassette(cassette_name): + repository = self.gh.repository('sigmavirus24', 'github3.py') + ref = repository.ref('tags/0.9.3') + + assert isinstance(ref, github3.git.Reference) + def test_release(self): """Test the ability to retrieve a single release.""" cassette_name = self.cassette_name('release') diff --git a/tests/test_repos.py b/tests/test_repos.py index e13836601..4322866b1 100644 --- a/tests/test_repos.py +++ b/tests/test_repos.py @@ -15,47 +15,6 @@ def setUp(self): self.repo = repos.Repository(self.repo.as_dict(), self.g) self.api = 'https://api.github.com/repos/sigmavirus24/github3.py/' - def test_milestone(self): - self.response('milestone', 200) - self.get(self.api + 'milestones/2') - - assert isinstance(self.repo.milestone(2), - github3.issues.milestone.Milestone) - self.mock_assertions() - - def test_parent(self): - json = self.repo.as_dict().copy() - json['parent'] = json.copy() - r = repos.Repository(json) - assert isinstance(r.parent, repos.Repository) - - def test_permissions(self): - json = load('repo') - permissions = {"admin": True, "push": True, "pull": True} - assert json['permissions'] == permissions - assert self.repo.permissions == permissions - - def test_pull_request(self): - self.response('pull', 200) - self.get(self.api + 'pulls/2') - - assert isinstance(self.repo.pull_request(2), github3.pulls.PullRequest) - self.mock_assertions() - - def test_readme(self): - self.response('readme', 200) - self.get(self.api + 'readme') - - assert isinstance(self.repo.readme(), repos.contents.Contents) - self.mock_assertions() - - def test_ref(self): - self.response('ref', 200) - self.get(self.api + 'git/refs/fakesha') - - assert isinstance(self.repo.ref('fakesha'), github3.git.Reference) - self.mock_assertions() - def test_remove_collaborator(self): self.response('', 204) self.delete(self.api + 'collaborators/login') diff --git a/tests/unit/json/repos_repo_example b/tests/unit/json/repos_repo_example index b27956b4b..b88e4b0f8 100644 --- a/tests/unit/json/repos_repo_example +++ b/tests/unit/json/repos_repo_example @@ -1,116 +1,287 @@ { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": false, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "subscribers_count": 42, + "organization": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { "id": 1296269, "owner": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, "name": "Hello-World", "full_name": "octocat/Hello-World", "description": "This your first repo!", "private": false, - "fork": false, + "fork": true, "url": "https://api.github.com/repos/octocat/Hello-World", "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", "clone_url": "https://github.com/octocat/Hello-World.git", - "git_url": "git://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", "svn_url": "https://svn.github.com/octocat/Hello-World", - "mirror_url": "git://git.example.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "homepage": "https://github.com", "language": null, - "forks": 9, "forks_count": 9, - "watchers": 80, + "stargazers_count": 80, "watchers_count": 80, "size": 108, - "master_branch": "master", - "open_issues": 0, + "default_branch": "master", "open_issues_count": 0, + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", - "organization": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat", - "type": "Organization" - }, - "parent": { - "id": 1296269, - "owner": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, - "name": "Hello-World", - "full_name": "octocat/Hello-World", - "description": "This your first repo!", - "private": false, - "fork": true, - "url": "https://api.github.com/repos/octocat/Hello-World", - "html_url": "https://github.com/octocat/Hello-World", - "clone_url": "https://github.com/octocat/Hello-World.git", - "git_url": "git://github.com/octocat/Hello-World.git", - "ssh_url": "git@github.com:octocat/Hello-World.git", - "svn_url": "https://svn.github.com/octocat/Hello-World", - "mirror_url": "git://git.example.com/octocat/Hello-World", - "homepage": "https://github.com", - "language": null, - "forks": 9, - "forks_count": 9, - "watchers": 80, - "watchers_count": 80, - "size": 108, - "master_branch": "master", - "open_issues": 0, - "open_issues_count": 0, - "pushed_at": "2011-01-26T19:06:43Z", - "created_at": "2011-01-26T19:01:12Z", - "updated_at": "2011-01-26T19:14:43Z" - }, - "source": { - "id": 1296269, - "owner": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat.gif", - "gravatar_id": "somehexcode", - "url": "https://api.github.com/users/octocat" - }, - "name": "Hello-World", - "full_name": "octocat/Hello-World", - "description": "This your first repo!", - "private": false, - "fork": true, - "url": "https://api.github.com/repos/octocat/Hello-World", - "html_url": "https://github.com/octocat/Hello-World", - "clone_url": "https://github.com/octocat/Hello-World.git", - "git_url": "git://github.com/octocat/Hello-World.git", - "ssh_url": "git@github.com:octocat/Hello-World.git", - "svn_url": "https://svn.github.com/octocat/Hello-World", - "mirror_url": "git://git.example.com/octocat/Hello-World", - "homepage": "https://github.com", - "language": null, - "forks": 9, - "forks_count": 9, - "watchers": 80, - "watchers_count": 80, - "size": 108, - "master_branch": "master", - "open_issues": 0, - "open_issues_count": 0, - "pushed_at": "2011-01-26T19:06:43Z", - "created_at": "2011-01-26T19:01:12Z", - "updated_at": "2011-01-26T19:14:43Z" - }, + "permissions": { + "admin": false, + "push": false, + "pull": true + } + }, + "source": { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, "has_issues": true, "has_wiki": true, - "has_downloads": true + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + } + } } diff --git a/tests/unit/test_repos_repo.py b/tests/unit/test_repos_repo.py index 6e00c0794..ebebdfde0 100644 --- a/tests/unit/test_repos_repo.py +++ b/tests/unit/test_repos_repo.py @@ -765,6 +765,51 @@ def test_pages(self): self.session.get.assert_called_once_with(url_for('pages')) + def test_parent(self): + """Verify that parent of repository can be retrieved.""" + parent = self.instance.parent + assert isinstance(parent, Repository) + + def test_permission(self): + """Verify permissions of a repository can be retrieved.""" + permissions = { + 'admin': False, + 'push': False, + 'pull': True + } + assert self.instance.permissions == permissions + + def test_pull_request(self): + """Verify the request for retrieving a pull request.""" + self.instance.pull_request(1) + self.session.get.assert_called_once_with( + url_for('pulls/1') + ) + + def test_pull_request_required_number(self): + """Verify the request for retrieving a pull request.""" + self.instance.pull_request(-1) + assert self.session.get.called is False + + def test_readme(self): + """Verify the request for retrieving the README.""" + self.instance.readme() + self.session.get.assert_called_once_with( + url_for('readme') + ) + + def test_ref(self): + """Verify the request for retrieving a reference.""" + self.instance.ref('heads/develop') + self.session.get.assert_called_once_with( + url_for('git/refs/heads/develop') + ) + + def test_ref_required_ref(self): + """Verify the request for retrieving a reference.""" + self.instance.ref('') + assert self.session.get.called is False + def test_release_from_tag(self): """Test the request for retrieving release by tag name""" self.instance.release_from_tag('v1.0.0')