Ejemplo n.º 1
0
    def testStr(self):
        FLAGS.pyatdl_show_uid = False
        FLAGS.pyatdl_separator = '/'
        lst = tdl.ToDoList()
        self.assertEqual(lst.inbox.name, 'inbox')
        self.assertEqual(lst.root.name, '')
        self.assertEqual(lst.root.items, [])
        # pylint: disable=trailing-whitespace
        self._AssertEqualWithDiff(
            """
<todolist>
    <inbox>
        <project is_deleted="False" is_complete="False" is_active="True" name="inbox">
       \x20
        </project>
    </inbox>
    <folder is_deleted="False" name="">
   \x20
    </folder>
    <contexts>
        <context_list is_deleted="False" name="Contexts">
       \x20
        </context_list>
    </contexts>
</todolist>
""".strip().split('\n'),
            str(lst).split('\n'))
 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 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)
Ejemplo n.º 4
0
    def setUp(self):
        super().setUp()

        random.seed(3737123)

        FLAGS.pyatdl_randomize_uids = False

        assert _helpers.GetHelpWidth
        _helpers.GetHelpWidth = lambda: 180
        uid.ResetNotesOfExistingUIDs()

        # There is a gflags.TextWrap glitch re: the line '-a,--[no]show_all:
        # Additionally lists everything, even hidden objects, overriding the view
        # filter' so we replace TextWrap.
        def MyTextWrap(text,
                       length=None,
                       indent='',
                       firstline_indent=None,
                       tabs='    '):  # pylint: disable=unused-argument
            return text

        flags.TextWrap = MyTextWrap
        FLAGS.pyatdl_allow_exceptions_in_batch_mode = True
        FLAGS.pyatdl_separator = '/'
        FLAGS.pyatdl_break_glass_and_skip_wellformedness_check = False
        FLAGS.pyatdl_give_full_help_for_uicmd = False
        FLAGS.pyatdl_paranoia = True
        FLAGS.pyatdl_allow_command_line_comments = False
        FLAGS.pyatdl_zlib_compression_level = 6
        FLAGS.pyatdl_show_uid = False
        FLAGS.seed_upon_creation = False
        FLAGS.no_context_display_string = '<none>'
        FLAGS.time_format = '%Y/%m/%d-%H:%M:%S'
        FLAGS.timezone = 'US/Eastern'
        self.saved_time = time.time
        time.time = lambda: 36
        self.todolist = tdl.ToDoList()
        time.time = self.saved_time
        self.saved_input = immaculater._Input  # pylint: disable=protected-access
        self.saved_print = immaculater._Print  # pylint: disable=protected-access
        self.maxDiff = None  # pylint: disable=invalid-name
        tf = self._NamedTempFile()
        FLAGS.database_filename = tf.name
        tf.close()
        self.saved_decompress = zlib.decompress
 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)