def assertMergeResults(self,
                           before,
                           after,
                           mock_filesystem_contents,
                           inputargs,
                           filesystem_contains,
                           json_data_merger=None):
        mock_filesystem = MockFileSystem(mock_filesystem_contents,
                                         dirs=['/output'])

        file_merger = merge_results.MergeFilesJSONP(mock_filesystem,
                                                    json_data_merger)
        file_merger(*inputargs)
        files = mock_filesystem.files_under('/output')
        self.assertTrue(len(files) == 1)
        expected_mock_filesystem = MockFileSystem(filesystem_contains)
        expected_files = expected_mock_filesystem.files_under('/output')
        actual_output = mock_filesystem.read_text_file(files[0])
        expected_output = expected_mock_filesystem.read_text_file(
            expected_files[0])
        self.assertTrue(self.check_before_after(actual_output, before, after))
        self.assertTrue(self.check_before_after(expected_output, before,
                                                after))
        actual_json_str = self.remove_before_after(actual_output, before,
                                                   after)
        expected_json_str = self.remove_before_after(expected_output, before,
                                                     after)
        self.assertEqual(json.loads(actual_json_str),
                         json.loads(expected_json_str))
    def assertMergeRaises(self, mock_filesystem_contents, inputargs):
        mock_filesystem = MockFileSystem(mock_filesystem_contents,
                                         dirs=['/output'])

        file_merger = merge_results.MergeFilesJSONP(mock_filesystem)
        with self.assertRaises(merge_results.MergeFailure):
            file_merger(*inputargs)
Exemplo n.º 3
0
    def assertMergeResults(self,
                           mock_filesystem_contents,
                           inputargs,
                           filesystem_contains,
                           json_data_merger=None):
        mock_filesystem = MockFileSystem(mock_filesystem_contents,
                                         dirs=['/output'])

        file_merger = merge_results.MergeFilesJSONP(mock_filesystem,
                                                    json_data_merger)
        with self.assertFilesAdded(mock_filesystem, filesystem_contains):
            file_merger(*inputargs)