from dqc_wrapper.test03_temporal_completeness import TemporalCompletenessTest, add_month
from dqc_wrapper.unit_tests.conftest import dirs
from datetime import datetime, date
from dateutil.relativedelta import relativedelta


def test_add_month():
    today = datetime.combine(date.today(), datetime.min.time())
    res = add_month(date.today())
    assert res == today + relativedelta(months=1)


def test_check_timestamps():
    # Mocked nc is temporal complete
    test = TemporalCompletenessTest(dirs.log_dir, 'test.ini', [dirs.nc_file], dirs.test_dir,  '', 'tas',
                                    '', '', 'no', 'yes')
    response = test.check_timestamps()
    assert response[0] == 'ok'

    # Mocked grib isn't
    test = TemporalCompletenessTest(dirs.log_dir, 'test.ini', [dirs.grib_file], dirs.test_dir, '',
                                    'tas', '', '', 'no', 'yes')
    response = test.check_timestamps()
    assert response[0] == 'err'