def test_failure_same_file_but_contents_differ(self): mock_filesystem = MockFileSystem({ '/shard0/file1': '1', '/shard1/file1': '2' }) d = merge_results.DirMerger(mock_filesystem) with self.assertRaises(merge_results.MergeFailure): d.merge('/output', ['/shard0', '/shard1'])
def test_success_same_file_but_matching_contents(self): mock_filesystem = MockFileSystem({ '/shard0/file1': '1', '/shard1/file1': '1' }) d = merge_results.DirMerger(mock_filesystem) with self.assertFilesAdded(mock_filesystem, {'/output/file1': '1'}): d.merge('/output', ['/shard0', '/shard1'])
def test_failure_on_output_existing(self): mock_filesystem = MockFileSystem({}, dirs=['/output']) d = merge_results.DirMerger(mock_filesystem) with self.assertRaises(OSError): d.merge('/output', []) self.assertDictEqual({}, mock_filesystem.files, "No new files should exist!")
def test_success_no_overlapping_files(self): mock_filesystem = MockFileSystem({ '/shard0/file1': '1', '/shard1/file2': '2' }) d = merge_results.DirMerger(mock_filesystem) with self.assertFilesAdded(mock_filesystem, { '/output/file1': '1', '/output/file2': '2' }): d.merge('/output', ['/shard0', '/shard1'])