def testMergeNoneSomething(self):
     something = pyatdl_pb2.ToDoList()
     with self.assertRaisesRegex(TypeError,
                                 "both of the arguments must be present"):
         mergeprotobufs.Merge(None, something)
     with self.assertRaisesRegex(TypeError,
                                 "both of the arguments must be present"):
         mergeprotobufs.Merge(tdl.ToDoList(), None)
 def testMergeInboxNameChangedWithTimestampDifferenceLeft(self):
     thing1 = pyatdl_pb2.ToDoList()
     thing1.inbox.CopyFrom(prj.Prj(name="my password is hunter2").AsProto())
     thing2 = pyatdl_pb2.ToDoList()
     thing2.CopyFrom(thing1)
     thing2.inbox.common.metadata.name = "my password is *******"
     thing2.inbox.common.timestamp.mtime -= 1000
     self.assertProtosEqual(mergeprotobufs.Merge(thing1, thing2), thing1)
 def testMergeInboxNameChangedWithoutTimestampDifference(self):
     prj1 = prj.Prj(the_uid=uid.INBOX_UID, name="my password is hunter2")
     uid.ResetNotesOfExistingUIDs()
     thing1 = tdl.ToDoList(inbox=prj.Prj.DeserializedProtobuf(
         prj1.AsProto().SerializeToString()))
     thing2 = pyatdl_pb2.ToDoList()
     thing2.CopyFrom(thing1.AsProto())
     thing2.inbox.common.metadata.name = "my password is *******"
     merged = pyatdl_pb2.ToDoList()
     merged.CopyFrom(thing1.AsProto())
     merged.MergeFrom(thing2)
     self.assertProtosEqual(mergeprotobufs.Merge(thing1, thing2), merged)
 def testMerge1right(self):
     thing1, thing2 = tdl.ToDoList(), pyatdl_pb2.ToDoList()
     thing2.inbox.CopyFrom(prj.Prj(name="xyz").AsProto())
     self.assertProtosEqual(mergeprotobufs.Merge(thing1, thing2), thing2)
 def testMerge0(self):
     thing1, thing2 = tdl.ToDoList(), pyatdl_pb2.ToDoList()
     self.assertProtosEqual(mergeprotobufs.Merge(thing1, thing2), thing1)
 def testMergeNoneNone(self):
     with self.assertRaisesRegex(TypeError,
                                 "both of the arguments must be present"):
         mergeprotobufs.Merge(None, None)