from dqc_wrapper.test00_file_format import FileFormatCheck
from dqc_wrapper.unit_tests.conftest import dirs


def test_eccodes_return_format():
    test = FileFormatCheck([dirs.grib_file])
    response = test.eccodes_return_format(dirs.grib_file)
    assert 'GRIB' in response


def test_netcdf_return_format():
    test = FileFormatCheck([dirs.nc_file])
    response = test.netcdf_return_format(dirs.nc_file)
    assert 'netcdf' in response.lower()


def test_file_return_format():
    test = FileFormatCheck([dirs.nc_file])
    response = test.file_return_format(__file__)
    assert 'python' in response.lower()


def test_append_formats():
    test = FileFormatCheck([dirs.nc_file])
    formats = test.append_formats([], dirs.nc_file)
    assert len(formats) == 1
    assert 'netcdf' in formats[0].lower()


def test_zip_return_formats():
    test = FileFormatCheck([dirs.zip_file])
    response = test.zip_return_formats(dirs.zip_file)
    assert 'netcdf' in ",".join(response).lower()
    assert 'grib' in ",".join(response).lower()


def test_main():
    test = FileFormatCheck([dirs.grib_file])
    response = test.main()
    assert 'res' in response.keys() and response['res'] == 'ok'
    assert 'msg' in response.keys()


