def test_get_logname(): path = ffi.new('char [2048]', b'foobar/') idnum = 3 filename = ffi.new('char [2048]') print([type(o) for o in (path, idnum, filename)]) assert vic_lib.get_logname(path, idnum, filename) is None print(ffi.string(filename)) assert len(ffi.string(filename)) > 0
def test_get_current_datetime(): dts = ffi.new('char [2048]') assert len(ffi.string(dts)) == 0 vic_lib.get_current_datetime(dts) assert len(ffi.string(dts)) == 14 now = datetime.datetime.now() now_string = now.strftime('%Y%m%d') assert now_string == ffi.string(dts)[:8].decode()
def dmy(scope='function'): d = ffi.new('dmy_struct *') d[0].day = 1 d[0].day_in_year = 1 d[0].dayseconds = 1234 d[0].month = 1 d[0].year = 1984 return d