Skip to content

Commit 76558b7

Browse files
Add: test for packages API from github (#1049)
* 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 <jaspar.stach@greenbone.net>
1 parent e3149be commit 76558b7

File tree

10 files changed

+1060
-916
lines changed

10 files changed

+1060
-916
lines changed

pontos/github/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818
from .labels import GitHubAsyncRESTLabels
1919
from .organizations import GitHubAsyncRESTOrganizations
20+
from .packages import GitHubAsyncRESTPackages
2021
from .pull_requests import GitHubAsyncRESTPullRequests
2122
from .release import GitHubAsyncRESTReleases
2223
from .repositories import GitHubAsyncRESTRepositories
@@ -39,6 +40,7 @@
3940
"GitHubAsyncRESTDependabot",
4041
"GitHubAsyncRESTLabels",
4142
"GitHubAsyncRESTOrganizations",
43+
"GitHubAsyncRESTPackages",
4244
"GitHubAsyncRESTPullRequests",
4345
"GitHubAsyncRESTReleases",
4446
"GitHubAsyncRESTRepositories",

pontos/github/api/api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
)
2323
from pontos.github.api.labels import GitHubAsyncRESTLabels
2424
from pontos.github.api.organizations import GitHubAsyncRESTOrganizations
25+
from pontos.github.api.packages import GitHubAsyncRESTPackages
2526
from pontos.github.api.pull_requests import GitHubAsyncRESTPullRequests
2627
from pontos.github.api.release import GitHubAsyncRESTReleases
2728
from pontos.github.api.repositories import GitHubAsyncRESTRepositories
@@ -120,6 +121,13 @@ def labels(self) -> GitHubAsyncRESTLabels:
120121
"""
121122
return GitHubAsyncRESTLabels(self._client)
122123

124+
@property
125+
def packages(self) -> GitHubAsyncRESTPackages:
126+
"""
127+
Packages related API
128+
"""
129+
return GitHubAsyncRESTPackages(self._client)
130+
123131
@property
124132
@deprecated(
125133
since="23.3.4",

pontos/github/api/foo.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
'id': 4917607,
3+
'name': 'asset-management-backend',
4+
'package_type': 'container',
5+
'owner': {
6+
'login': 'greenbone',
7+
'id': 31986857,
8+
'node_id': 'MDEyOk9yZ2FuaXphdGlvbjMxOTg2ODU3',
9+
'avatar_url': 'https: //avatars.githubusercontent.com/u/31986857?v=4',
10+
'gravatar_id': '',
11+
'url': 'https://api.github.com/users/greenbone',
12+
'html_url': 'https://github.com/greenbone',
13+
'followers_url': 'https://api.github.com/users/greenbone/followers',
14+
'following_url': 'https://api.github.com/users/greenbone/following{/other_user}',
15+
'gists_url': 'https://api.github.com/users/greenbone/gists{/gist_id}',
16+
'starred_url': 'https://api.github.com/users/greenbone/starred{/owner}{/repo}',
17+
'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
18+
},
19+
'version_count': 7686,
20+
'visibility': 'public',
21+
'url': 'https://api.github.com/orgs/greenbone/packages/container/asset-management-backend',
22+
'created_at': '2023-03-16T14:39:23Z',
23+
'updated_at': '2024-05-06T07:46:34Z',
24+
'repository': {
25+
'id': 498688333,
26+
'node_id': 'R_kgDOHblhTQ',
27+
'name': 'asset-management-backend',
28+
'full_name': 'greenbone/asset-management-backend',
29+
'private': True,
30+
'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
31+
},
32+
'html_url': 'https://github.com/greenbone/asset-management-backend',
33+
'description': 'Backend for the asset-management-frontend that provides REST endpoints with the main functionality of the Opensight Asset product.',
34+
'fork': False,
35+
'url': 'https://api.github.com/repos/greenbone/asset-management-backend',
36+
'forks_url': 'https://api.github.com/repos/greenbone/asset-management-backend/forks',
37+
'keys_url': 'https://api.github.com/repos/greenbone/asset-management-backend/keys{/key_id}',
38+
'collaborators_url': 'https://api.github.com/repos/greenbone/asset-management-backend/collaborators{/collaborator}',
39+
'teams_url': 'https://api.github.com/repos/greenbone/asset-management-backend/teams',
40+
'hooks_url': 'https://api.github.com/repos/greenbone/asset-management-backend/hooks',
41+
'issue_events_url': 'https://api.github.com/repos/greenbone/asset-management-backend/issues/events{/number}',
42+
'events_url': 'https://api.github.com/repos/greenbone/asset-management-backend/events',
43+
'assignees_url': 'https://api.github.com/repos/greenbone/asset-management-backend/assignees{/user}',
44+
'branches_url': 'https://api.github.com/repos/greenbone/asset-management-backend/branches{/branch}',
45+
'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',
46+
'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}',
47+
'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}',
48+
'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}',
49+
'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}',
50+
'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}',
51+
'deployments_url': 'https://api.github.com/repos/greenbone/asset-management-backend/deployments'
52+
},
53+
'html_url': 'https://github.com/orgs/greenbone/packages/container/package/asset-management-backend'
54+
}

0 commit comments

Comments
 (0)