def test_update_return_proper_patches(self): archive_index = ArchiveMessageIndex(MessageDao()) new_messages = archive_index.update(test_data_path()) self.assertEqual(len(new_messages), 8) subjects = ['Re: [PATCH] Remove final reference to superfluous smp_commence().', '[PATCH v2 1/3] dmaengine: add dma_get_channel_caps()', '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands', '[PATCH v2 0/4] kselftests/arm64: add PAuth tests', '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test', '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests', '[PATCH v2 3/4] kselftests/arm64: add PAuth test for whether exec() changes keys', '[PATCH v2 4/4] kselftests/arm64: add PAuth tests for single threaded consistency and key uniqueness'] compare_message_subjects(self, new_messages, subjects)
def test_parse_comments_for_single_email_thread(self): archive_index = ArchiveMessageIndex(MessageDao()) archive_index.update(test_data_path()) patchset = parse_comments( archive_index.find( '<20200827144112.v2.1.I6981f9a9f0c12e60f8038f3b574184f8ffc1b9b5@changeid>' )) self.assertTrue(len(patchset.patches) > 0) first_patch = patchset.patches[0] self.assertEqual(first_patch.set_index, 0) self.assertNotEqual(first_patch.text, '') self.assertIn( '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands', first_patch.text_with_headers) self.assertEqual(first_patch.comments, [])
def test_split_parent_and_reply_messages(self): archive_index = ArchiveMessageIndex(MessageDao()) messages = archive_index.update(test_data_path()) parents, replies = Server.split_parent_and_reply_messages(messages) self.assertEqual(len(parents), 2) self.assertEqual(len(replies), 6) expected_parents = ['[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands', '[PATCH v2 0/4] kselftests/arm64: add PAuth tests'] expected_replies = ['Re: [PATCH] Remove final reference to superfluous smp_commence().', '[PATCH v2 1/3] dmaengine: add dma_get_channel_caps()', '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test', '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests', '[PATCH v2 3/4] kselftests/arm64: add PAuth test for whether exec() changes keys', '[PATCH v2 4/4] kselftests/arm64: add PAuth tests for single threaded consistency and key uniqueness'] compare_message_subjects(self, parents, expected_parents) compare_message_subjects(self, replies, expected_replies)
def test_parse_comments_for_multi_email_thread_with_cover_letter(self): archive_index = ArchiveMessageIndex(MessageDao()) archive_index.update(test_data_path()) patchset = parse_comments( archive_index.find( '<*****@*****.**>')) self.assertEqual(len(patchset.patches), 4) first_patch = patchset.patches[0] self.assertEqual(first_patch.set_index, 1) self.assertIn( '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test', first_patch.text_with_headers) self.assertNotEqual(first_patch.text, '') self.assertEqual(first_patch.comments, []) self.assertIn( '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests', patchset.patches[1].text_with_headers)
def test_server_upload_across_batches(self, mock_upload_comments, mock_upload_messages, mock_fill_message_directory): archive_index = ArchiveMessageIndex(MessageDao()) messages = archive_index.update(test_data_path()) # Make sure the ordering is deterministic. messages.sort(key=lambda m: m.id) first_batch = messages[0:6] second_batch = messages[6:] mock_fill_message_directory.return_value = '' # declaring mock objects here because I want to use the ArchiveMessageIndex functionality to build the test data with mock.patch.object(ArchiveMessageIndex, 'update') as mock_update, mock.patch.object(MessageDao, 'get') as mock_get: mock_update.side_effect = [first_batch, second_batch] mock_get.side_effect = [None, None, messages[6], messages[7]] server = Server() server.update_convert_upload() mock_upload_messages.assert_called_with([messages[2].id,messages[3].id]) mock_upload_comments.assert_called_with(set()) server.update_convert_upload() mock_upload_messages.assert_called_with([messages[6].id,messages[7].id]) mock_upload_comments.assert_called_with(set())
def test_parse_with_replies(self): archive_index = ArchiveMessageIndex(MessageDao()) archive_index.update(test_data_path('fake_patch_with_replies/')) self.assertEqual(archive_index.size(), 2) patchset = parse_comments(archive_index.find('<patch-message-id>')) map_comments_to_gerrit(patchset) self.assertEqual(len(patchset.patches), 1) patch = patchset.patches[0] self.compareCommentsPartialMatch( patch.comments, [ # TODO: stop treating this as a comment Comment( raw_line=-1, file='', line=-1, message= 'On Mon, 31 Aug 2020 at 12:04:46 +0100, The Sender wrote:' ), Comment( raw_line=18, file='file', line=7, # TODO: should be 5 message='Comment on old line 5, want on line 5 in new file.' ), Comment( raw_line=20, file='file', line=9, # TODO: should be 7 message='Comment on old line 7, want on line 8 in new file.' ), ])
def test_update_with_no_changes_to_data(self): archive_index = ArchiveMessageIndex(MessageDao()) archive_index.update(test_data_path()) old_size = archive_index.size() archive_index.update(test_data_path()) self.assertEqual(old_size, archive_index.size())
def test_generate_email_from_single_email_thread(self): email = generate_email_from_file(test_data_path('patch6.txt')) self.assertEqual(email.subject, '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands') self.assertEqual(email.in_reply_to, None) self.assertEqual(email.from_, "Raul E Rangel <*****@*****.**>") self.assertTrue(len(email.content) > 0)
def test_parse_comments_for_non_patch_email(self): patchset = parse_comments( generate_email_from_file(test_data_path('thread_patch0.txt'))) self.assertEqual(len(patchset.patches), 0)