Skip to content

Commit

Permalink
Add tests for ‹get_sha_from_branch›
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Jan 3, 2022
1 parent aa601d5 commit 685904e
Show file tree
Hide file tree
Showing 9 changed files with 1,553 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
_requre:
DataTypes: 1
key_strategy: StorageKeysInspectSimple
version_storage_file: 3
requests.sessions:
send:
GET:
https://api.github.com:443/repos/packit/hello-world:
- metadata:
latency: 0.31723451614379883
module_call_list:
- unittest.case
- requre.record_and_replace
- tests.integration.github.test_generic_commands
- ogr.abstract
- ogr.services.github.project
- github.MainClass
- github.Requester
- requests.sessions
- requre.objects
- requre.cassette
- requests.sessions
- send
output:
__store_indicator: 2
_content:
allow_auto_merge: false
allow_forking: true
allow_merge_commit: true
allow_rebase_merge: true
allow_squash_merge: true
allow_update_branch: false
archive_url: https://api.github.com/repos/packit/hello-world/{archive_format}{/ref}
archived: false
assignees_url: https://api.github.com/repos/packit/hello-world/assignees{/user}
blobs_url: https://api.github.com/repos/packit/hello-world/git/blobs{/sha}
branches_url: https://api.github.com/repos/packit/hello-world/branches{/branch}
clone_url: https://github.com/packit/hello-world.git
collaborators_url: https://api.github.com/repos/packit/hello-world/collaborators{/collaborator}
comments_url: https://api.github.com/repos/packit/hello-world/comments{/number}
commits_url: https://api.github.com/repos/packit/hello-world/commits{/sha}
compare_url: https://api.github.com/repos/packit/hello-world/compare/{base}...{head}
contents_url: https://api.github.com/repos/packit/hello-world/contents/{+path}
contributors_url: https://api.github.com/repos/packit/hello-world/contributors
created_at: '2019-05-02T18:54:46Z'
default_branch: main
delete_branch_on_merge: false
deployments_url: https://api.github.com/repos/packit/hello-world/deployments
description: The most progresive command-line tool in the world.
disabled: false
downloads_url: https://api.github.com/repos/packit/hello-world/downloads
events_url: https://api.github.com/repos/packit/hello-world/events
fork: false
forks: 20
forks_count: 20
forks_url: https://api.github.com/repos/packit/hello-world/forks
full_name: packit/hello-world
git_commits_url: https://api.github.com/repos/packit/hello-world/git/commits{/sha}
git_refs_url: https://api.github.com/repos/packit/hello-world/git/refs{/sha}
git_tags_url: https://api.github.com/repos/packit/hello-world/git/tags{/sha}
git_url: git://github.com/packit/hello-world.git
has_downloads: true
has_issues: true
has_pages: false
has_projects: true
has_wiki: true
homepage: null
hooks_url: https://api.github.com/repos/packit/hello-world/hooks
html_url: https://github.com/packit/hello-world
id: 184635124
is_template: false
issue_comment_url: https://api.github.com/repos/packit/hello-world/issues/comments{/number}
issue_events_url: https://api.github.com/repos/packit/hello-world/issues/events{/number}
issues_url: https://api.github.com/repos/packit/hello-world/issues{/number}
keys_url: https://api.github.com/repos/packit/hello-world/keys{/key_id}
labels_url: https://api.github.com/repos/packit/hello-world/labels{/name}
language: Python
languages_url: https://api.github.com/repos/packit/hello-world/languages
license:
key: mit
name: MIT License
node_id: MDc6TGljZW5zZTEz
spdx_id: MIT
url: https://api.github.com/licenses/mit
merges_url: https://api.github.com/repos/packit/hello-world/merges
milestones_url: https://api.github.com/repos/packit/hello-world/milestones{/number}
mirror_url: null
name: hello-world
network_count: 20
node_id: MDEwOlJlcG9zaXRvcnkxODQ2MzUxMjQ=
notifications_url: https://api.github.com/repos/packit/hello-world/notifications{?since,all,participating}
open_issues: 57
open_issues_count: 57
organization:
avatar_url: https://avatars.githubusercontent.com/u/46870917?v=4
events_url: https://api.github.com/users/packit/events{/privacy}
followers_url: https://api.github.com/users/packit/followers
following_url: https://api.github.com/users/packit/following{/other_user}
gists_url: https://api.github.com/users/packit/gists{/gist_id}
gravatar_id: ''
html_url: https://github.com/packit
id: 46870917
login: packit
node_id: MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3
organizations_url: https://api.github.com/users/packit/orgs
received_events_url: https://api.github.com/users/packit/received_events
repos_url: https://api.github.com/users/packit/repos
site_admin: false
starred_url: https://api.github.com/users/packit/starred{/owner}{/repo}
subscriptions_url: https://api.github.com/users/packit/subscriptions
type: Organization
url: https://api.github.com/users/packit
owner:
avatar_url: https://avatars.githubusercontent.com/u/46870917?v=4
events_url: https://api.github.com/users/packit/events{/privacy}
followers_url: https://api.github.com/users/packit/followers
following_url: https://api.github.com/users/packit/following{/other_user}
gists_url: https://api.github.com/users/packit/gists{/gist_id}
gravatar_id: ''
html_url: https://github.com/packit
id: 46870917
login: packit
node_id: MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3
organizations_url: https://api.github.com/users/packit/orgs
received_events_url: https://api.github.com/users/packit/received_events
repos_url: https://api.github.com/users/packit/repos
site_admin: false
starred_url: https://api.github.com/users/packit/starred{/owner}{/repo}
subscriptions_url: https://api.github.com/users/packit/subscriptions
type: Organization
url: https://api.github.com/users/packit
permissions:
admin: true
maintain: true
pull: true
push: true
triage: true
private: false
pulls_url: https://api.github.com/repos/packit/hello-world/pulls{/number}
pushed_at: '2022-01-03T06:50:35Z'
releases_url: https://api.github.com/repos/packit/hello-world/releases{/id}
size: 58
ssh_url: [email protected]:packit/hello-world.git
stargazers_count: 4
stargazers_url: https://api.github.com/repos/packit/hello-world/stargazers
statuses_url: https://api.github.com/repos/packit/hello-world/statuses/{sha}
subscribers_count: 9
subscribers_url: https://api.github.com/repos/packit/hello-world/subscribers
subscription_url: https://api.github.com/repos/packit/hello-world/subscription
svn_url: https://github.com/packit/hello-world
tags_url: https://api.github.com/repos/packit/hello-world/tags
teams_url: https://api.github.com/repos/packit/hello-world/teams
temp_clone_token: ''
topics: []
trees_url: https://api.github.com/repos/packit/hello-world/git/trees{/sha}
updated_at: '2021-11-30T09:33:55Z'
url: https://api.github.com/repos/packit/hello-world
visibility: public
watchers: 4
watchers_count: 4
_next: null
elapsed: 0.315507
encoding: utf-8
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
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: Mon, 03 Jan 2022 11:57:10 GMT
ETag: W/"cad969bec821c8b7182c0f49a48de8b0fb5b0b1219bdd9e869c8e7d2900d72eb"
Last-Modified: Tue, 30 Nov 2021 09:33:55 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, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept,
X-Requested-With
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: C3CC:6210:A9ECCB6:ACB4237:61D2E496
X-OAuth-Scopes: admin:enterprise, admin:gpg_key, admin:org, admin:org_hook,
admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist,
notifications, repo, user, workflow, write:discussion, write:packages
X-RateLimit-Limit: '5000'
X-RateLimit-Remaining: '4995'
X-RateLimit-Reset: '1641214432'
X-RateLimit-Resource: core
X-RateLimit-Used: '5'
X-XSS-Protection: '0'
raw: !!binary ""
reason: OK
status_code: 200
https://api.github.com:443/repos/packit/hello-world/branches/non-existing:
- metadata:
latency: 0.19494342803955078
module_call_list:
- unittest.case
- requre.record_and_replace
- tests.integration.github.test_generic_commands
- ogr.abstract
- ogr.services.github.project
- github.Repository
- github.Requester
- requests.sessions
- requre.objects
- requre.cassette
- requests.sessions
- send
output:
__store_indicator: 2
_content:
documentation_url: https://docs.github.com/rest/reference/repos#get-a-branch
message: Branch not found
_next: null
elapsed: 0.192827
encoding: utf-8
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: Mon, 03 Jan 2022 11:57:10 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; format=json
X-GitHub-Request-Id: C3CC:6210:A9ECD1C:ACB4294:61D2E496
X-OAuth-Scopes: admin:enterprise, admin:gpg_key, admin:org, admin:org_hook,
admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist,
notifications, repo, user, workflow, write:discussion, write:packages
X-RateLimit-Limit: '5000'
X-RateLimit-Remaining: '4994'
X-RateLimit-Reset: '1641214432'
X-RateLimit-Resource: core
X-RateLimit-Used: '6'
X-XSS-Protection: '0'
raw: !!binary ""
reason: Not Found
status_code: 404
8 changes: 8 additions & 0 deletions tests/integration/github/test_generic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def test_commit_flags(self):
assert isinstance(flags, list)
assert len(flags) == 0

def test_get_sha_from_branch(self):
commit_sha = self.hello_world_project.get_sha_from_branch("test-for-flock")
assert commit_sha and commit_sha.startswith("e2282f3")

def test_get_sha_from_branch_non_existing(self):
commit_sha = self.hello_world_project.get_sha_from_branch("non-existing")
assert commit_sha is None

def test_get_sha_from_tag(self):
assert (
self.ogr_project.get_sha_from_tag("0.0.1")
Expand Down
Loading

0 comments on commit 685904e

Please sign in to comment.