'Test directory_source.get_new_files() when stat fails.'

def test_get_new_files_stat_fails(self):

    path = '/some/valid/path'
    os.listdir.expect_call(path).and_return(['file1', 'file2'])
    self._stat_mock.expect_call(os.path.join(path, 'file1')).and_raises(OSError('Error'))
    stat_result = self._get_stat_result(size=1010, mtime=123)
    file2_full_path = os.path.join(path, 'file2')
    self._stat_mock.expect_call(file2_full_path).and_return(stat_result)
    self.db_mock.get_dictionary.expect_call().and_return({})
    s = source.directory_source(self.db_mock, path)
    expected = {'file2': source.database.item(file2_full_path, 1010, 123)}
    self.assertEquals(expected, s.get_new_files(_stat_func=self._stat_mock))
    self.god.check_playback()
