def test_list_directories_uses_conn_if_specified(self): conn = Mock() conn.modules.os.listdir.return_value = ['dir1', 'file1', 'dir2'] list_directories('/some/path', conn) conn.modules.os.listdir.assert_called_once_with('/some/path') self.assertEqual(3, len(conn.modules.os.path.isdir.mock_calls))
def test_list_directories_filters_directories(self): self.os.listdir.return_value = ['dir1', 'file1', 'dir2'] mock_calls = [ call('/some/path', 'dir1'), call('/some/path', 'file1'), call('/some/path', 'dir2'), ] list_directories('/some/path') self.assertEqual(mock_calls, self.os.path.join.mock_calls) self.assertEqual(6, len(self.os.path.isdir.mock_calls))
def test_list_directories_returns_only_directories(self): self.os.listdir.return_value = ['dir1', 'dir2'] self.os.path.isdir.return_value = False ret = list_directories('/some/path') self.assertEqual([], ret)
def list_directories(self, path): return list_directories(path, self.rpyc_conn)
def list_buffer_hosts(): logger.debug("Generating a list of buffer host directories") buffer_path = os.path.join(MESSOR_BUFFER, 'hosts') return list_directories(buffer_path)
def test_list_directories_lists_dir(self): list_directories('/some/path') self.os.listdir.assert_called_once_with('/some/path')