예제 #1
0
 def test_process_NEWS_bad_news(self):
     """
     Test process_NEWS() function with irrelevant newsfile provided
     """
     with tempfile.TemporaryDirectory() as tmpd:
         commitmessage.build.download_path = tmpd
         with open(os.path.join(tmpd, 'NEWS'), 'w') as newsfile:
             # make GOOD_NEWS irrelevant by replacing current version
             newsfile.write(GOOD_NEWS.replace('0.0.1', '0.0.0'))
         self.assertEqual(commitmessage.process_NEWS('NEWS'), ([], set()))
예제 #2
0
 def test_process_NEWS(self):
     """
     Test process_NEWS() function with valid newsfile provided
     """
     with tempfile.TemporaryDirectory() as tmpd:
         commitmessage.build.download_path = tmpd
         with open(os.path.join(tmpd, 'NEWS'), 'w') as newsfile:
             newsfile.write(GOOD_NEWS)
         # commitmessage returned will have an empty string as first and
         # last items
         expected_msg = [""] + GOOD_NEWS.split('\n')[3:13]
         expected_cvs = set()
         self.assertEqual(commitmessage.process_NEWS('NEWS'),
                          (expected_msg, expected_cvs))
예제 #3
0
 def test_process_NEWS_good_cves(self):
     """
     Test process_NEWS() function with valid newsfile and CVEs
     """
     with tempfile.TemporaryDirectory() as tmpd:
         commitmessage.build.download_path = tmpd
         with open(os.path.join(tmpd, 'NEWS'), 'w') as newsfile:
             # give GOOD_NEWS some CVEs
             newsfile.write(GOOD_NEWS.replace('change2.1', 'CVE-2-1')
                                     .replace('change2.2', 'CVE-2-2'))
         # commitmessage returned will have an empty string as first and
         # last items.
         # replace change2.* strings with CVE strings
         expected_msg = [""] + GOOD_NEWS.replace('change2.1', 'CVE-2-1')\
                                        .replace('change2.2', 'CVE-2-2')\
                                        .split('\n')[3:13]
         expected_cvs = set(['CVE-2-1', 'CVE-2-2'])
         self.assertEqual(commitmessage.process_NEWS('NEWS', '0.0.0', '', '0.0.1'),
                          (expected_msg, expected_cvs))
예제 #4
0
 def test_process_NEWS_long(self):
     """
     Test process_NEWS() function with valid newsfile provided, but relevant
     block is longer than 15 lines, causing it to be truncated.
     """
     with tempfile.TemporaryDirectory() as tmpd:
         commitmessage.build.download_path = tmpd
         long_news = GOOD_NEWS.replace('text explaining change2.2',
                                       '1\n2\n3\n4\n5\n6\n7\n8\n9\n')
         with open(os.path.join(tmpd, 'NEWS'), 'w') as newsfile:
             newsfile.write(long_news)
         # commitmessage returned will have an empty string as first and
         # last items, extend the expected message with extra lines and
         # truncate message.
         expected_msg = [""] + GOOD_NEWS.split('\n')[3:11]
         expected_msg.extend(['1', '2', '3', '4', '5', '6', '7', '',
                              '(NEWS truncated at 15 lines)', ''])
         expected_cvs = set()
         self.assertEqual(commitmessage.process_NEWS('NEWS', '0.0.0', '', '0.0.1'),
                          (expected_msg, expected_cvs))