import pytest
from dqc_wrapper.test06_valid_ranges import ValidRangesTest
from dqc_wrapper.checker import create_parser

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

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


def initialize(file_path, type_format='netcdf'):
    args = create_parser(['--test', 'valid_ranges', '--input',
                          file_path, '--type', type_format])
    return ValidRangesTest(args)

""" UNIT TESTS """

""" INTEGRATION TESTS """
def test_main_nc(ncfile):
    test = initialize(ncfile)
    test.main()


def test_main_grib(gribfile):
    test = initialize(gribfile, type_format='grib')
    test.main()


def test_main_error():
    with pytest.raises(Exception):
        test = initialize(type_format=None)
        test.main()

test_main_nc("/home/suareze/git/Python/c3s512/c3s512-wp1-datachecker/dqc_wrapper/test_testers/sample.nc")