def test_leap_second_by_date():
    ait.config.leapseconds._config['filename'] = os.path.join(os.path.dirname(__file__), 'testdata', 'dmc', 'leapseconds.dat')
    ls = dmc.LeapSeconds
    ls._load_leap_second_data()
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1981, 1, 1)) == 0)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1981, 7, 1)) == 1)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1982, 7, 1)) == 2)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1983, 7, 1)) == 3)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1985, 7, 1)) == 4)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1988, 1, 1)) == 5)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1990, 1, 1)) == 6)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1991, 1, 1)) == 7)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1992, 7, 1)) == 8)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1993, 7, 1)) == 9)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1994, 7, 1)) == 10)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1996, 1, 1)) == 11)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1997, 7, 1)) == 12)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1999, 1, 1)) == 13)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2006, 1, 1)) == 14)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2009, 1, 1)) == 15)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2012, 7, 1)) == 16)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2015, 7, 1)) == 17)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2017, 1, 1)) == 18)
    assert (ls.get_GPS_offset_for_date(datetime.datetime.utcnow()) == ls.get_GPS_offset_for_date())
def test_leap_second_by_date():
    ait.config.leapseconds._config['filename'] = os.path.join(os.path.dirname(__file__), 'testdata', 'dmc', 'leapseconds.dat')
    ls = dmc.LeapSeconds
    ls._load_leap_second_data()
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1981, 1, 1)) == 0)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1981, 7, 1)) == 1)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1982, 7, 1)) == 2)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1983, 7, 1)) == 3)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1985, 7, 1)) == 4)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1988, 1, 1)) == 5)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1990, 1, 1)) == 6)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1991, 1, 1)) == 7)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1992, 7, 1)) == 8)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1993, 7, 1)) == 9)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1994, 7, 1)) == 10)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1996, 1, 1)) == 11)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1997, 7, 1)) == 12)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(1999, 1, 1)) == 13)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2006, 1, 1)) == 14)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2009, 1, 1)) == 15)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2012, 7, 1)) == 16)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2015, 7, 1)) == 17)
    assert (ls.get_GPS_offset_for_date(datetime.datetime(2017, 1, 1)) == 18)
    assert (ls.get_GPS_offset_for_date(datetime.datetime.utcnow()) == ls.get_GPS_offset_for_date())