Skip to content

Commit

Permalink
test: add testing for non existent branch
Browse files Browse the repository at this point in the history
Signed-off-by: joseph-sentry <[email protected]>
  • Loading branch information
joseph-sentry committed Aug 30, 2023
1 parent 7a4bdac commit 62a17de
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
interactions:
- request:
body: ''
headers:
accept:
- application/json
accept-encoding:
- gzip, deflate
connection:
- keep-alive
host:
- api.github.com
user-agent:
- Default
method: GET
uri: https://api.github.com/repos/ThiagoCodecov/example-python/branches/none
response:
content: '{"message":"Branch not found","documentation_url":"https://docs.github.com/rest/branches/branches#get-a-branch"}'
headers:
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
X-GitHub-Request-Id, Deprecation, Sunset
Content-Encoding:
- gzip
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json; charset=utf-8
Date:
- Wed, 30 Aug 2023 14:16:40 GMT
Referrer-Policy:
- origin-when-cross-origin, strict-origin-when-cross-origin
Server:
- GitHub.com
Strict-Transport-Security:
- max-age=31536000; includeSubdomains; preload
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding, Accept, X-Requested-With
X-Accepted-OAuth-Scopes:
- ''
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- deny
X-GitHub-Media-Type:
- github.v3
X-GitHub-Request-Id:
- FAF3:54E5:1518A8A:2AFCA6E:64EF4F48
X-OAuth-Scopes:
- repo
X-RateLimit-Limit:
- '5000'
X-RateLimit-Remaining:
- '4938'
X-RateLimit-Reset:
- '1693406893'
X-RateLimit-Resource:
- core
X-RateLimit-Used:
- '62'
X-XSS-Protection:
- '0'
github-authentication-token-expiration:
- 2023-09-29 14:15:09 UTC
x-github-api-version-selected:
- '2022-11-28'
http_version: HTTP/1.1
status_code: 404
version: 1
10 changes: 9 additions & 1 deletion tests/integration/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from shared.torngit.exceptions import (
TorngitObjectNotFoundError,
TorngitRepoNotFoundError,
TorngitClientGeneralError,
)
from shared.torngit.github import Github

Expand All @@ -14,7 +15,6 @@ def valid_handler():
repo=dict(name="example-python"),
owner=dict(username="ThiagoCodecov"),
token=dict(key=10 * "a280"),
on_token_refresh=lambda token: token,
)


Expand Down Expand Up @@ -636,6 +636,14 @@ async def test_get_branch(self, valid_handler, codecov_vcr):
print(branch)
assert branch == expected_result

@pytest.mark.asyncio
async def test_get_branch_not_existent(self, valid_handler, codecov_vcr):
with pytest.raises(TorngitClientGeneralError) as e:
branch = await valid_handler.get_branch("none")
print(branch)
assert e[0] == 404
assert e[1]["message"] == "Branch not found"

@pytest.mark.asyncio
async def test_post_webhook(self, valid_handler, codecov_vcr):
url = "http://requestbin.net/r/1ecyaj51"
Expand Down

0 comments on commit 62a17de

Please sign in to comment.