Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Deployment class with API spec #3121

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix linting
  • Loading branch information
EnricoMi committed Jan 7, 2025
commit 0f79b77d587205a432a421802a02e55cca529f4e
12 changes: 8 additions & 4 deletions github/Deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from __future__ import annotations

from datetime import datetime
from typing import Any
from typing import TYPE_CHECKING, Any

import github.Consts
import github.DeploymentStatus
Expand All @@ -54,6 +54,10 @@
from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt
from github.PaginatedList import PaginatedList

if TYPE_CHECKING:
from github.GithubApp import GithubApp
from github.NamedUser import NamedUser


class Deployment(CompletableGithubObject):
"""
Expand All @@ -71,7 +75,7 @@ class Deployment(CompletableGithubObject):

def _initAttributes(self) -> None:
self._created_at: Attribute[datetime] = NotSet
self._creator: Attribute[github.NamedUser.NamedUser] = NotSet
self._creator: Attribute[NamedUser] = NotSet
self._description: Attribute[str] = NotSet
self._environment: Attribute[str] = NotSet
self._id: Attribute[int] = NotSet
Expand Down Expand Up @@ -99,7 +103,7 @@ def created_at(self) -> datetime:
return self._created_at.value

@property
def creator(self) -> github.NamedUser.NamedUser:
def creator(self) -> NamedUser:
self._completeIfNotSet(self._creator)
return self._creator.value

Expand Down Expand Up @@ -139,7 +143,7 @@ def payload(self) -> dict[str, Any]:
return self._payload.value

@property
def performed_via_github_app(self) -> github.GithubApp.GithubApp:
def performed_via_github_app(self) -> GithubApp:
self._completeIfNotSet(self._performed_via_github_app)
return self._performed_via_github_app.value

Expand Down
25 changes: 14 additions & 11 deletions tests/Deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,24 @@ def setUp(self):

def testAttributes(self):
self.assertEqual(self.deployment.created_at, datetime(2020, 8, 26, 11, 44, 53, tzinfo=timezone.utc))
self.assertEqual(self.deployment.creator.login, 'jacquev6')
self.assertEqual(self.deployment.description, 'Test deployment')
self.assertEqual(self.deployment.environment, 'test')
self.assertEqual(self.deployment.creator.login, "jacquev6")
self.assertEqual(self.deployment.description, "Test deployment")
self.assertEqual(self.deployment.environment, "test")
self.assertEqual(self.deployment.id, 263877258)
self.assertIsNone(self.deployment.message)
self.assertEqual(self.deployment.node_id, 'MDEwOkRlcGxveW1lbnQyNjIzNTE3NzY=')
self.assertEqual(self.deployment.original_environment, 'test')
self.assertEqual(self.deployment.payload, {'test': True})
self.assertEqual(self.deployment.node_id, "MDEwOkRlcGxveW1lbnQyNjIzNTE3NzY=")
self.assertEqual(self.deployment.original_environment, "test")
self.assertEqual(self.deployment.payload, {"test": True})
self.assertIsNone(self.deployment.performed_via_github_app)
self.assertEqual(self.deployment.production_environment, False)
self.assertEqual(self.deployment.ref, '743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5')
self.assertEqual(self.deployment.repository_url, 'https://api.github.com/repos/jacquev6/PyGithub')
self.assertEqual(self.deployment.sha, '743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5')
self.assertEqual(self.deployment.statuses_url, 'https://api.github.com/repos/jacquev6/PyGithub/deployments/263877258/statuses')
self.assertEqual(self.deployment.task, 'deploy')
self.assertEqual(self.deployment.ref, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5")
self.assertEqual(self.deployment.repository_url, "https://api.github.com/repos/jacquev6/PyGithub")
self.assertEqual(self.deployment.sha, "743f5a58b0bce91c4eab744ff7e39dfca9e6e8a5")
self.assertEqual(
self.deployment.statuses_url,
"https://api.github.com/repos/jacquev6/PyGithub/deployments/263877258/statuses",
)
self.assertEqual(self.deployment.task, "deploy")
self.assertEqual(self.deployment.transient_environment, True)
self.assertEqual(self.deployment.updated_at, datetime(2020, 8, 26, 11, 44, 53, tzinfo=timezone.utc))
self.assertEqual(
Expand Down
Loading