Skip to content

Commit

Permalink
Add: test for packages API from github (#1049)
Browse files Browse the repository at this point in the history
* Add: packages API from github

* Refactor: Reuse JSON instead of hardcoding every occurance ...

* WiP: Add tests, test functionallity

* Add: Test script to get the ID of a package with a specific tag.

* Fix tests

* Add test for package_versions

* Add: Test for package_version_tags

* Change: Some typo

* Test: debugging for packages.py error

* Add: Tests for delete and tags

* Fix: Local pathfinding not working on github

* Fix: Indentation

* Refractor

* Remove: Broken code to check other tests

* Change: Removed unnecessary print

* Add: test_delete_package

* Add: test_delete_package_version_tag

* Add: Test for Api.py line 129

* Change:Debugging delete_package_version_tag

* Fix:Package_version missing

* Remove: Package self check

* Add: Print tags

* Removed: Test

* Add: Delete package(s) with specific tag

* Fix: Newline and iterator

* Fix: Function not existing so i removed the call

* Fix: missing await

* Fix: Iterator type error

* Fix: missing async

* Fix: Async Iterator

* Fix: Iterator

* A commit

* Iterator

* Change: Different try on iterator

* Get_All

* New tests

* Iterator stuff

* Change: Change package_versions back to old version

* Change: New try

* Fix: Test_package_versions

* Refractor

* Refractor

* Refractor

* Refractor

* Some debugging

* Debug: Type fail

* Type fixes

* Type problemes

* Change: Updated the test_delete_package_with_tag

* Remove: Duplicated test

* Fix: Test had wront wait

* Remove: Unnecessary test

* Refractor: imports

* Add: Extended tests

* Fix: Container was in lower case

* Fix: wrong url for second delete

* Change: Moved the failuretest

* Add: test for lines

* Remove: Not working tests

* Remove: Unnecessary code block

* Change: Code cleanup

* Delete awaited once still failing

* Debugging

* Debugging

* Debugging

* Debugging

* Remove:trailing spaces

* Remove: Trailing spaces

* Test package_version_delete and package_version_tags

* Commit for staging

* Add: working unit tests, Refractor

* Add: Script to use delete by tag

* Refractor: packages.py, delete-package-with-tag.py, test_packages.py

* Refractor: delete-package-with-tag

---------

Co-authored-by: Jaspar Stach <[email protected]>
  • Loading branch information
gabrielschowe and y0urself authored Sep 24, 2024
1 parent e3149be commit 76558b7
Show file tree
Hide file tree
Showing 10 changed files with 1,060 additions and 916 deletions.
2 changes: 2 additions & 0 deletions pontos/github/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)
from .labels import GitHubAsyncRESTLabels
from .organizations import GitHubAsyncRESTOrganizations
from .packages import GitHubAsyncRESTPackages
from .pull_requests import GitHubAsyncRESTPullRequests
from .release import GitHubAsyncRESTReleases
from .repositories import GitHubAsyncRESTRepositories
Expand All @@ -39,6 +40,7 @@
"GitHubAsyncRESTDependabot",
"GitHubAsyncRESTLabels",
"GitHubAsyncRESTOrganizations",
"GitHubAsyncRESTPackages",
"GitHubAsyncRESTPullRequests",
"GitHubAsyncRESTReleases",
"GitHubAsyncRESTRepositories",
Expand Down
8 changes: 8 additions & 0 deletions pontos/github/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from pontos.github.api.labels import GitHubAsyncRESTLabels
from pontos.github.api.organizations import GitHubAsyncRESTOrganizations
from pontos.github.api.packages import GitHubAsyncRESTPackages
from pontos.github.api.pull_requests import GitHubAsyncRESTPullRequests
from pontos.github.api.release import GitHubAsyncRESTReleases
from pontos.github.api.repositories import GitHubAsyncRESTRepositories
Expand Down Expand Up @@ -120,6 +121,13 @@ def labels(self) -> GitHubAsyncRESTLabels:
"""
return GitHubAsyncRESTLabels(self._client)

@property
def packages(self) -> GitHubAsyncRESTPackages:
"""
Packages related API
"""
return GitHubAsyncRESTPackages(self._client)

@property
@deprecated(
since="23.3.4",
Expand Down
54 changes: 54 additions & 0 deletions pontos/github/api/foo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
'id': 4917607,
'name': 'asset-management-backend',
'package_type': 'container',
'owner': {
'login': 'greenbone',
'id': 31986857,
'node_id': 'MDEyOk9yZ2FuaXphdGlvbjMxOTg2ODU3',
'avatar_url': 'https: //avatars.githubusercontent.com/u/31986857?v=4',
'gravatar_id': '',
'url': 'https://api.github.com/users/greenbone',
'html_url': 'https://github.com/greenbone',
'followers_url': 'https://api.github.com/users/greenbone/followers',
'following_url': 'https://api.github.com/users/greenbone/following{/other_user}',
'gists_url': 'https://api.github.com/users/greenbone/gists{/gist_id}',
'starred_url': 'https://api.github.com/users/greenbone/starred{/owner}{/repo}',
'subscriptions_url': 'https://api.github.com/users/greenbone/subscriptions', 'organizations_url': 'https://api.github.com/users/greenbone/orgs', 'repos_url': 'https://api.github.com/users/greenbone/repos', 'events_url': 'https://api.github.com/users/greenbone/events{/privacy}', 'received_events_url': 'https://api.github.com/users/greenbone/received_events', 'type': 'Organization', 'site_admin': False
},
'version_count': 7686,
'visibility': 'public',
'url': 'https://api.github.com/orgs/greenbone/packages/container/asset-management-backend',
'created_at': '2023-03-16T14:39:23Z',
'updated_at': '2024-05-06T07:46:34Z',
'repository': {
'id': 498688333,
'node_id': 'R_kgDOHblhTQ',
'name': 'asset-management-backend',
'full_name': 'greenbone/asset-management-backend',
'private': True,
'owner': {'login': 'greenbone', 'id': 31986857, 'node_id': 'MDEyOk9yZ2FuaXphdGlvbjMxOTg2ODU3', 'avatar_url': 'https://avatars.githubusercontent.com/u/31986857?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/greenbone', 'html_url': 'https://github.com/greenbone', 'followers_url': 'https://api.github.com/users/greenbone/followers', 'following_url': 'https://api.github.com/users/greenbone/following{/other_user}', 'gists_url': 'https://api.github.com/users/greenbone/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/greenbone/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/greenbone/subscriptions', 'organizations_url': 'https://api.github.com/users/greenbone/orgs', 'repos_url': 'https://api.github.com/users/greenbone/repos', 'events_url': 'https://api.github.com/users/greenbone/events{/privacy}', 'received_events_url': 'https://api.github.com/users/greenbone/received_events', 'type': 'Organization', 'site_admin': False
},
'html_url': 'https://github.com/greenbone/asset-management-backend',
'description': 'Backend for the asset-management-frontend that provides REST endpoints with the main functionality of the Opensight Asset product.',
'fork': False,
'url': 'https://api.github.com/repos/greenbone/asset-management-backend',
'forks_url': 'https://api.github.com/repos/greenbone/asset-management-backend/forks',
'keys_url': 'https://api.github.com/repos/greenbone/asset-management-backend/keys{/key_id}',
'collaborators_url': 'https://api.github.com/repos/greenbone/asset-management-backend/collaborators{/collaborator}',
'teams_url': 'https://api.github.com/repos/greenbone/asset-management-backend/teams',
'hooks_url': 'https://api.github.com/repos/greenbone/asset-management-backend/hooks',
'issue_events_url': 'https://api.github.com/repos/greenbone/asset-management-backend/issues/events{/number}',
'events_url': 'https://api.github.com/repos/greenbone/asset-management-backend/events',
'assignees_url': 'https://api.github.com/repos/greenbone/asset-management-backend/assignees{/user}',
'branches_url': 'https://api.github.com/repos/greenbone/asset-management-backend/branches{/branch}',
'tags_url': 'https://api.github.com/repos/greenbone/asset-management-backend/tags', 'blobs_url': 'https://api.github.com/repos/greenbone/asset-management-backend/git/blobs{/sha}', 'git_tags_url': 'https://api.github.com/repos/greenbone/asset-management-backend/git/tags{/sha}', 'git_refs_url': 'https://api.github.com/repos/greenbone/asset-management-backend/git/refs{/sha}', 'trees_url': 'https://api.github.com/repos/greenbone/asset-management-backend/git/trees{/sha}', 'statuses_url': 'https://api.github.com/repos/greenbone/asset-management-backend/statuses/{sha}', 'languages_url': 'https://api.github.com/repos/greenbone/asset-management-backend/languages', 'stargazers_url': 'https://api.github.com/repos/greenbone/asset-management-backend/stargazers', 'contributors_url': 'https://api.github.com/repos/greenbone/asset-management-backend/contributors',
'subscribers_url': 'https://api.github.com/repos/greenbone/asset-management-backend/subscribers', 'subscription_url': 'https://api.github.com/repos/greenbone/asset-management-backend/subscription', 'commits_url': 'https://api.github.com/repos/greenbone/asset-management-backend/commits{/sha}',
'git_commits_url': 'https://api.github.com/repos/greenbone/asset-management-backend/git/commits{/sha}', 'comments_url': 'https://api.github.com/repos/greenbone/asset-management-backend/comments{/number}', 'issue_comment_url': 'https://api.github.com/repos/greenbone/asset-management-backend/issues/comments{/number}',
'contents_url': 'https://api.github.com/repos/greenbone/asset-management-backend/contents/{+path}', 'compare_url': 'https://api.github.com/repos/greenbone/asset-management-backend/compare/{base}...{head}', 'merges_url': 'https://api.github.com/repos/greenbone/asset-management-backend/merges', 'archive_url': 'https://api.github.com/repos/greenbone/asset-management-backend/{archive_format}{/ref}',
'downloads_url': 'https://api.github.com/repos/greenbone/asset-management-backend/downloads', 'issues_url': 'https://api.github.com/repos/greenbone/asset-management-backend/issues{/number}', 'pulls_url': 'https://api.github.com/repos/greenbone/asset-management-backend/pulls{/number}', 'milestones_url': 'https://api.github.com/repos/greenbone/asset-management-backend/milestones{/number}',
'notifications_url': 'https://api.github.com/repos/greenbone/asset-management-backend/notifications{?since,all,participating}', 'labels_url': 'https://api.github.com/repos/greenbone/asset-management-backend/labels{/name}', 'releases_url': 'https://api.github.com/repos/greenbone/asset-management-backend/releases{/id}',
'deployments_url': 'https://api.github.com/repos/greenbone/asset-management-backend/deployments'
},
'html_url': 'https://github.com/orgs/greenbone/packages/container/package/asset-management-backend'
}
Loading

0 comments on commit 76558b7

Please sign in to comment.