from dqc_wrapper.utils.utils_grib import *
from dqc_wrapper.unit_tests.conftest import dirs


def test_load_grib_metadata():
    metadata = load_grib_metadata()
    assert 'grib_codes' in metadata[list(metadata.keys())[0]]


def test_grib_get_max_resolution():
    res = grib_get_max_resolution(dirs.grib_cds)
    assert res == 319225


def test_get_message_list():
    test = GribFileCheck(dirs.grib_cds)
    msgs = test.get_message_list()
    assert len(msgs) == 3


def test_check_mandatory_keys():
    test = GribFileCheck(dirs.grib_cds)
    err_msgs = test.check_mandatory_keys({'GRIBEditionNumber': '2'})
    assert not len(err_msgs)
    err_msgs = test.check_mandatory_keys({'GRIBEditionNumber': '27'})
    assert len(err_msgs)


def test_get_grib_version():
    test = GribFileCheck(dirs.grib_cds)
    res = test.get_grib_version()
    assert res == 2