File: test_artifact.py

package info (click to toggle)
pontos 25.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,744 kB
  • sloc: python: 44,602; makefile: 21; sh: 10; xml: 3
file content (71 lines) | stat: -rw-r--r-- 2,591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-FileCopyrightText: 2022-2023 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

# pylint: disable=line-too-long

import unittest
from datetime import datetime, timezone

from pontos.github.models.artifact import Artifact


class ArtifactTestCase(unittest.TestCase):
    def test_from_dict(self):
        artifact = Artifact.from_dict(
            {
                "id": 1,
                "node_id": "MDg6QXJ0aWZhY3QxMQ==",
                "name": "Rails",
                "size_in_bytes": 556,
                "url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11",
                "archive_download_url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11/zip",
                "expired": False,
                "created_at": "2020-01-10T14:59:22Z",
                "expires_at": "2020-03-21T14:59:22Z",
                "updated_at": "2020-02-21T14:59:22Z",
                "workflow_run": {
                    "id": 1,
                    "repository_id": 2,
                    "head_repository_id": 3,
                    "head_branch": "main",
                    "head_sha": "328faa0536e6fef19753d9d91dc96a9931694ce3",
                },
            }
        )

        self.assertEqual(artifact.id, 1)
        self.assertEqual(artifact.node_id, "MDg6QXJ0aWZhY3QxMQ==")
        self.assertEqual(artifact.name, "Rails")
        self.assertEqual(artifact.size_in_bytes, 556)
        self.assertEqual(
            artifact.url,
            "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11",
        )
        self.assertEqual(
            artifact.archive_download_url,
            "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11/zip",
        )
        self.assertFalse(artifact.expired)
        self.assertEqual(
            artifact.created_at,
            datetime(2020, 1, 10, 14, 59, 22, tzinfo=timezone.utc),
        )
        self.assertEqual(
            artifact.expires_at,
            datetime(2020, 3, 21, 14, 59, 22, tzinfo=timezone.utc),
        )
        self.assertEqual(
            artifact.updated_at,
            datetime(2020, 2, 21, 14, 59, 22, tzinfo=timezone.utc),
        )

        workflow_run = artifact.workflow_run
        self.assertEqual(workflow_run.id, 1)
        self.assertEqual(workflow_run.repository_id, 2)
        self.assertEqual(workflow_run.head_repository_id, 3)
        self.assertEqual(workflow_run.head_branch, "main")
        self.assertEqual(
            workflow_run.head_sha, "328faa0536e6fef19753d9d91dc96a9931694ce3"
        )