diff options
Diffstat (limited to 'pydis_site/apps/api')
| -rw-r--r-- | pydis_site/apps/api/github_utils.py | 4 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_github_utils.py | 7 | 
2 files changed, 5 insertions, 6 deletions
| diff --git a/pydis_site/apps/api/github_utils.py b/pydis_site/apps/api/github_utils.py index 986c64e1..44c571c3 100644 --- a/pydis_site/apps/api/github_utils.py +++ b/pydis_site/apps/api/github_utils.py @@ -11,8 +11,6 @@ from pydis_site import settings  MAX_RUN_TIME = datetime.timedelta(minutes=10)  """The maximum time allowed before an action is declared timed out.""" -ISO_FORMAT_STRING = "%Y-%m-%dT%H:%M:%SZ" -"""The datetime string format GitHub uses."""  class ArtifactProcessingError(Exception): @@ -147,7 +145,7 @@ def authorize(owner: str, repo: str) -> httpx.Client:  def check_run_status(run: WorkflowRun) -> str:      """Check if the provided run has been completed, otherwise raise an exception.""" -    created_at = datetime.datetime.strptime(run.created_at, ISO_FORMAT_STRING) +    created_at = datetime.datetime.strptime(run.created_at, settings.GITHUB_TIMESTAMP_FORMAT)      run_time = datetime.datetime.utcnow() - created_at      if run.status != "completed": diff --git a/pydis_site/apps/api/tests/test_github_utils.py b/pydis_site/apps/api/tests/test_github_utils.py index 2eaf48d9..95bafec0 100644 --- a/pydis_site/apps/api/tests/test_github_utils.py +++ b/pydis_site/apps/api/tests/test_github_utils.py @@ -11,6 +11,7 @@ import rest_framework.response  import rest_framework.test  from django.urls import reverse +from pydis_site import settings  from .. import github_utils @@ -49,7 +50,7 @@ class CheckRunTests(unittest.TestCase):          "head_sha": "sha",          "status": "completed",          "conclusion": "success", -        "created_at": datetime.datetime.utcnow().strftime(github_utils.ISO_FORMAT_STRING), +        "created_at": datetime.datetime.utcnow().strftime(settings.GITHUB_TIMESTAMP_FORMAT),          "artifacts_url": "url",      } @@ -74,7 +75,7 @@ class CheckRunTests(unittest.TestCase):          # to guarantee the right conclusion          kwargs["created_at"] = (              datetime.datetime.utcnow() - github_utils.MAX_RUN_TIME - datetime.timedelta(minutes=10) -        ).strftime(github_utils.ISO_FORMAT_STRING) +        ).strftime(settings.GITHUB_TIMESTAMP_FORMAT)          with self.assertRaises(github_utils.RunTimeoutError):              github_utils.check_run_status(github_utils.WorkflowRun(**kwargs)) @@ -178,7 +179,7 @@ class ArtifactFetcherTests(unittest.TestCase):                  run = github_utils.WorkflowRun(                      name="action_name",                      head_sha="action_sha", -                    created_at=datetime.datetime.now().strftime(github_utils.ISO_FORMAT_STRING), +                    created_at=datetime.datetime.now().strftime(settings.GITHUB_TIMESTAMP_FORMAT),                      status="completed",                      conclusion="success",                      artifacts_url="artifacts_url" | 
