示例#1
0
def main():
    c = Context()
    pr = PR(c.author, c.pr_number, c.url, c.change_token, c.body, categories=c.categories)
    pr.parse_body()

    if not pr.changes:
        print("PR has no changes worthy enough to mention in changelog, skipping :)")
        system('echo "::set-output name=generated_changelog::0"')
        return

    doc = Document(c.filename, pr.str_changes)
    system('echo "::set-output name=generated_changelog::1"')
    system(f'echo "::set-output name=changelog_content::{doc.raw_text}"')
示例#2
0
 def test_category_when_not_required(self):
     with mock.patch.dict(self.test_data, {"body": "CL: [Wrong] wrong category"}):
         pr = PR(**self.test_data)
         pr.parse_body()
         self.assertEqual(pr.changes[0].category, "Wrong")
示例#3
0
 def test_invalid_category(self):
     with mock.patch.dict(self.test_data, {"body": "CL: [Wrong] wrong category", "categories": self.categories}):
         pr = PR(**self.test_data)
         self.assertRaises(InvalidCategory, pr.parse_body)
示例#4
0
 def test_changes_1_missing_required_category(self):
     with mock.patch.dict(self.test_data, {"body": self.body_multiple, "categories": self.categories}):
         pr = PR(**self.test_data)
         self.assertRaises(MissingCategory, pr.parse_body)
示例#5
0
 def test_change_missing_required_category(self):
     with mock.patch.dict(self.test_data, {"body": "CL: fixed a bug", "categories": self.categories}):
         pr = PR(**self.test_data)
         self.assertRaises(MissingCategory, pr.parse_body)
示例#6
0
 def test_change_no_category_not_required(self):
     pr = PR(**self.test_data)
     try:
         pr.parse_body()
     except MissingCategory:
         self.fail("Category was not required. We shouldn't have raised exception.")
示例#7
0
 def test_change_has_category(self):
     pr = PR(**self.test_data)
     pr.parse_body()
     self.assertTrue(pr.changes[0].category)
示例#8
0
 def test_find_changes_in_body_3(self):
     with mock.patch.dict(self.test_data, {"body": self.body_multiple}):
         pr = PR(**self.test_data)
         pr.parse_body()
         self.assertEqual(3, len(pr.changes))
示例#9
0
 def test_find_change_in_body(self):
     pr = PR(**self.test_data)
     pr.parse_body()
     self.assertEqual(1, len(pr.changes))