Exemple #1
0
    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))
Exemple #2
0
    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))
Exemple #3
0
    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)
Exemple #4
0
    def list_directories(self, path):
	return list_directories(path, self.rpyc_conn)
Exemple #5
0
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)
Exemple #6
0
    def test_list_directories_lists_dir(self):
        list_directories('/some/path')

        self.os.listdir.assert_called_once_with('/some/path')