• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fedora-llvm-team / llvm-snapshots / 10286413170

07 Aug 2024 02:36PM UTC coverage: 67.503% (-0.3%) from 67.834%
10286413170

push

github

web-flow
Fix TestTestingFarmUtil.test_fetch_failed_test_cases_from_file (#634)

`TestingFarmRequest` now can be put into test-mode which allows to fetch
failed test cases from file rather than URL.

Fixes #632

6 of 7 new or added lines in 1 file covered. (85.71%)

196 existing lines in 6 files now uncovered.

1049 of 1554 relevant lines covered (67.5%)

0.68 hits per line

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

91.67
/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 tests.base_test as base_test
1✔
8

9
import snapshot_manager.github_util as github_util
1✔
10

11

12
class TestGithub(base_test.TestBase):
1✔
13
    def test_create_or_get_todays_github_issue(self):
1✔
14
        """Creates or gets today's github issue"""
15
        gh = github_util.GithubClient(config=self.config)
1✔
16
        issue, _ = gh.create_or_get_todays_github_issue(creator="kwk")
1✔
17
        self.assertIsNotNone(issue)
1✔
18

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

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

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

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

51
        issue = gh.get_todays_github_issue(
1✔
52
            strategy="big-merge", github_repo="fedora-llvm-team/llvm-snapshots"
53
        )
54

55
        self.assertIsNotNone(issue)
1✔
56
        self.assertEqual(287, issue.number)
1✔
57

58
        # Example: Get issue when in fact, no issue was created (should be always True for the day after tomorrow)
59
        cfg.datetime = datetime.datetime.now(datetime.UTC) + datetime.timedelta(days=2)
1✔
60
        issue = gh.get_todays_github_issue(
1✔
61
            strategy="big-merge", github_repo="fedora-llvm-team/llvm-snapshots"
62
        )
63
        self.assertIsNone(issue)
1✔
64

65
    def test_flip_test_label(self):
1✔
66
        gh = github_util.GithubClient(config=self.config)
1✔
67
        issue = gh.gh_repo.create_issue(
1✔
68
            title=f"TestGithub.test_flip_test_label {uuid.uuid4()}",
69
            body="This comment is for testing TestGithub.test_flip_test_label",
70
        )
71
        self.assertIsNotNone(issue)
1✔
72

73
        # Remove all labels
74
        logging.info(f"Removing all labels from issue: {issue.html_url}")
1✔
75
        for label in issue.get_labels():
1✔
UNCOV
76
            issue.remove_from_labels(label)
×
77
        self.assertEqual(issue.get_labels().totalCount, 0)
1✔
78

79
        # Ensure those labels that we need for our test exist
80
        chroot = "fedora-rawhide-x86_64"
1✔
81
        all_chroots = [chroot]
1✔
82
        logging.info("Creating test labels")
1✔
83
        gh.create_labels_for_in_testing(all_chroots)
1✔
84
        gh.create_labels_for_tests_failed_on(all_chroots)
1✔
85
        gh.create_labels_for_tested_on(all_chroots)
1✔
86

87
        in_testing = gh.label_in_testing(chroot=chroot)
1✔
88
        failed_on = gh.label_failed_on(chroot=chroot)
1✔
89
        tested_on = gh.label_tested_on(chroot=chroot)
1✔
90

91
        all_test_states = [in_testing, failed_on, tested_on]
1✔
92
        for test_state in all_test_states:
1✔
93
            logging.info(f"Flipping test label for chroot {chroot} to: {test_state}")
1✔
94
            gh.flip_test_label(issue, chroot, test_state)
1✔
95
            labels = issue.get_labels()
1✔
96
            self.assertIsNotNone(labels)
1✔
97
            self.assertEqual(labels.totalCount, 1)
1✔
98
            page = labels.get_page(0)
1✔
99
            self.assertIsNotNone(page)
1✔
100
            self.assertEqual(page[0].name, test_state)
1✔
101
        pass
1✔
102

103
    def test_get_workflow(self):
1✔
104
        gh = github_util.GithubClient(config=self.config)
1✔
105
        repo = gh.github.get_repo("fedora-llvm-team/llvm-snapshots")
1✔
106
        workflow = repo.get_workflow("check-snapshots.yml")
1✔
107
        self.assertIsNotNone(workflow)
1✔
108

109

110
def load_tests(loader, tests, ignore):
1✔
111
    """We want unittest to pick up all of our doctests
112

113
    See https://docs.python.org/3/library/unittest.html#load-tests-protocol
114
    See https://stackoverflow.com/a/27171468
115
    """
UNCOV
116
    import doctest
×
117

118
    import snapshot_manager.github_util
×
119

120
    tests.addTests(doctest.DocTestSuite(snapshot_manager.github_util))
×
UNCOV
121
    return tests
×
122

123

124
if __name__ == "__main__":
1✔
UNCOV
125
    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