def testWeekend(self): """ Test weekend encoder. """ p = DateEncoderParameters() p.custom_width = 21 p.custom_days = ["sat,sun,fri"] p.verbose = False e = DateEncoder(p) p = DateEncoderParameters() p.weekend_width = 21 e2 = DateEncoder(p) d = datetime.datetime(1988, 5, 29, 20, 00) #print(d) self.assertEqual(e.encode(d), e2.encode(d)) for _ in range(300): d = d + datetime.timedelta(days=1) self.assertEqual(e.encode(d), e2.encode(d))
def testJSONSerialization(self): """ This test is to insure that Python can access the C++ serialization functions. Serialization is tested more completely in C++ unit tests. Just checking that Python can access it. """ p = DateEncoderParameters() p.custom_width = 21 p.custom_days = ["sat,sun,fri"] p.verbose = False e1 = DateEncoder(p) # serialize filename = 'DateEncoder_serialize.json' e1.saveToFile(filename, 'JSON') e2 = DateEncoder() e2.loadFromFile(filename, 'JSON') d = datetime.datetime(1988, 5, 29, 20, 00) #print(d) self.assertEqual(e1.encode(d), e2.encode(d)) os.remove(filename)