import pytest
from dqc_wrapper.unit_tests.conftest import dirs
from dqc_wrapper.utils.utils_forms import *


def test_get_forms_dates():
    response = get_forms_dates('', 'tas', '', '', dirs.test_dir)
    assert len(response) == 2
    with pytest.raises(Exception):
        get_forms_dates('asd', 'tas', '', '', dirs.test_dir)


def test_get_param_id():
    response = get_param_id('', 'tas', dirs.test_dir)
    assert response == '171129'
    with pytest.raises(Exception):
        get_param_id('asd', 'tas', dirs.test_dir)
    with pytest.raises(Exception):
        get_param_id('', 'fake_var', dirs.test_dir)


def test_get_shortname_url():
    response = get_shortname_url('https://apps.ecmwf.int/codes/grib/param-db/?id=1')
    assert response == 'strf'

