• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

fedora-llvm-team / llvm-snapshots / 13137950566

04 Feb 2025 02:40PM UTC coverage: 38.173% (-0.1%) from 38.322%
13137950566

Pull #1063

github

web-flow
Merge c770c07ef into f5421dcb3
Pull Request #1063: Skip tests that require access to the token

16 of 16 new or added lines in 3 files covered. (100.0%)

46 existing lines in 5 files now uncovered.

9726 of 25479 relevant lines covered (38.17%)

0.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

32.1
/snapshot_manager/tests/github_util_test.py
1
""" Tests for github """
2

3
import datetime
1✔
4
import logging
1✔
5
import uuid
1✔
6

7
import pytest
1✔
8
import tests.base_test as base_test
1✔
9

10
import snapshot_manager.github_util as github_util
1✔
11

12

13
class TestGithub(base_test.TestBase):
1✔
14
    @pytest.mark.skip(reason="Skip this for now because of token issue")
1✔
15
    def test_create_or_get_todays_github_issue(self):
1✔
16
        """Creates or gets today's github issue"""
17
        gh = github_util.GithubClient(config=self.config)
×
18
        issue, _ = gh.create_or_get_todays_github_issue(creator="kwk")
×
19
        self.assertIsNotNone(issue)
×
20

21
        marker = "<!--HIDE_COMMMENT-->"
×
22
        comment = gh.create_or_update_comment(
×
23
            issue=issue, comment_body=f"{marker} Comment to be hidden", marker=marker
24
        )
25
        self.assertTrue(gh.minimize_comment_as_outdated(comment))
×
26

27
        marker = "<!--HIDE_AND_UNHIDE_COMMMENT-->"
×
28
        comment = gh.create_or_update_comment(
×
29
            issue=issue,
30
            comment_body=f"{marker} Comment to be hidden and unhidden",
31
            marker=marker,
32
        )
33
        self.assertTrue(gh.minimize_comment_as_outdated(comment))
×
34
        self.assertTrue(gh.unminimize_comment(comment))
×
35

36
        marker = "<!--REACT_TO_COMMMENT-->"
×
37
        comment = gh.create_or_update_comment(
×
38
            issue=issue, comment_body=f"{marker} Comment to react to", marker=marker
39
        )
40
        self.assertTrue(gh.add_comment_reaction(comment, github_util.Reaction.HEART))
×
41
        self.assertTrue(
×
42
            gh.add_comment_reaction(comment, github_util.Reaction.THUMBS_UP)
43
        )
44

45
    def test_get_todays_issue(self):
1✔
46
        """Get today's github issue"""
47
        # Example: Get issue for day in the past
48
        cfg = self.config
1✔
49
        cfg.datetime = datetime.datetime(year=2024, month=2, day=27)
1✔
50
        self.assertEqual("20240227", cfg.yyyymmdd)
1✔
51

52
        try:
1✔
53
            gh = github_util.GithubClient(config=cfg)
1✔
54
        except github_util.MissingToken:
1✔
55
            pytest.skip(
1✔
56
                "Skip test because this execution doesn't have access to a Github token"
57
            )
58

UNCOV
59
        issue = gh.get_todays_github_issue(
×
60
            strategy="big-merge", github_repo="fedora-llvm-team/llvm-snapshots"
61
        )
62

UNCOV
63
        self.assertIsNotNone(issue)
×
UNCOV
64
        self.assertEqual(287, issue.number)
×
65

66
        # Example: Get issue when in fact, no issue was created (should be always True for the day after tomorrow)
UNCOV
67
        cfg.datetime = datetime.datetime.now(datetime.UTC) + datetime.timedelta(days=2)
×
UNCOV
68
        issue = gh.get_todays_github_issue(
×
69
            strategy="big-merge", github_repo="fedora-llvm-team/llvm-snapshots"
70
        )
UNCOV
71
        self.assertIsNone(issue)
×
72

73
    @pytest.mark.skip(reason="Skip this for now because of token issue")
1✔
74
    def test_flip_test_label(self):
1✔
75
        gh = github_util.GithubClient(config=self.config)
×
76
        issue = gh.gh_repo.create_issue(
×
77
            title=f"TestGithub.test_flip_test_label {uuid.uuid4()}",
78
            body="This comment is for testing TestGithub.test_flip_test_label",
79
        )
80
        self.assertIsNotNone(issue)
×
81

82
        # Remove all labels
83
        logging.info(f"Removing all labels from issue: {issue.html_url}")
×
84
        for label in issue.get_labels():
×
85
            issue.remove_from_labels(label)
×
86
        self.assertEqual(issue.get_labels().totalCount, 0)
×
87

88
        # Ensure those labels that we need for our test exist
89
        chroot = "fedora-rawhide-x86_64"
×
90
        all_chroots = [chroot]
×
91
        logging.info("Creating test labels")
×
92
        gh.create_labels_for_in_testing(all_chroots)
×
93
        gh.create_labels_for_tests_failed_on(all_chroots)
×
94
        gh.create_labels_for_tested_on(all_chroots)
×
95

96
        in_testing = gh.label_in_testing(chroot=chroot)
×
97
        failed_on = gh.label_failed_on(chroot=chroot)
×
98
        tested_on = gh.label_tested_on(chroot=chroot)
×
99

100
        all_test_states = [in_testing, failed_on, tested_on]
×
101
        for test_state in all_test_states:
×
102
            logging.info(f"Flipping test label for chroot {chroot} to: {test_state}")
×
103
            gh.flip_test_label(issue, chroot, test_state)
×
104
            labels = issue.get_labels()
×
105
            self.assertIsNotNone(labels)
×
106
            self.assertEqual(labels.totalCount, 1)
×
107
            page = labels.get_page(0)
×
108
            self.assertIsNotNone(page)
×
109
            self.assertEqual(page[0].name, test_state)
×
110
        pass
×
111

112
    def test_get_workflow(self):
1✔
113
        try:
1✔
114
            gh = github_util.GithubClient(config=self.config)
1✔
115
        except github_util.MissingToken:
1✔
116
            pytest.skip(
1✔
117
                "Skip test because this execution doesn't have access to a Github token"
118
            )
119

UNCOV
120
        repo = gh.github.get_repo("fedora-llvm-team/llvm-snapshots")
×
UNCOV
121
        workflow = repo.get_workflow("check-snapshots.yml")
×
UNCOV
122
        self.assertIsNotNone(workflow)
×
123

124

125
def load_tests(loader, tests, ignore):
1✔
126
    """We want unittest to pick up all of our doctests
127

128
    See https://docs.python.org/3/library/unittest.html#load-tests-protocol
129
    See https://stackoverflow.com/a/27171468
130
    """
131
    import doctest
×
132

133
    import snapshot_manager.github_util
×
134

135
    tests.addTests(doctest.DocTestSuite(snapshot_manager.github_util))
×
136
    return tests
×
137

138

139
if __name__ == "__main__":
1✔
140
    base_test.run_tests()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc