import pytest, os
from dqc_wrapper.utils import commons

@pytest.fixture()
def ncfile(pytestconfig):
    return pytestconfig.getoption("ncfile")

def test_list_files_folder(ncfile):
    files_folder = os.path.dirname(ncfile)
    result = commons.list_files_folder(files_folder)
    assert len(result) == 2
    with pytest.raises(Exception):
        commons.list_files_folder('fake_path')

def test_dir_or_file(ncfile):
    should_be_file = commons.dir_or_file(ncfile)
    assert len(should_be_file) == 1
    should_be_dir = commons.dir_or_file(os.path.dirname(ncfile))
    assert len(should_be_dir) > 1
    with pytest.raises(Exception):
        commons.dir_or_file("fake_path")