Ejemplo n.º 1
0
 def add_item(self, item_text):
     """Turn a line of text into a TodoTxtItem object, then append it to our
     list of those objects."""
     if item_text.strip():
         new_list_item = TodoTxtItem()
         new_list_item.init_from_text(item_text)
         self.items.append(new_list_item)
Ejemplo n.º 2
0
 def add_item(self, item_text):
     """Turn a line of text into a TodoTxtItem object, then append it to our
     list of those objects."""
     if item_text.strip():
         new_list_item = TodoTxtItem()
         new_list_item.init_from_text(item_text)
         self.items.append(new_list_item)
Ejemplo n.º 3
0
    def test_init_from_text_completion_and_priority(self):
        item = 'x (R) Good thing I completed this'

        test_item = TodoTxtItem()
        test_item.init_from_text(item)

        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.priority, 'R')
        self.assertEqual(test_item.text, 'Good thing I completed this')
Ejemplo n.º 4
0
    def test_init_from_text_completion_and_priority(self):
        item = 'x (R) Good thing I completed this'

        test_item = TodoTxtItem()
        test_item.init_from_text(item)

        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.priority, 'R')
        self.assertEqual(test_item.text, 'Good thing I completed this')
Ejemplo n.º 5
0
    def test_from_string_back_to_string(self):
        original_item = 'x (Z) Here we go again'
        some_whitespace = 'x    (B)    This one is pretty weird'

        test_item = TodoTxtItem()
        test_item.init_from_text(original_item)
        self.assertEqual(original_item, str(test_item))

        test_item.init_from_text(some_whitespace)
        self.assertEqual('x (B) This one is pretty weird', str(test_item))
Ejemplo n.º 6
0
    def test_from_string_back_to_string(self):
        original_item = 'x (Z) Here we go again'
        some_whitespace = 'x    (B)    This one is pretty weird'

        test_item = TodoTxtItem()
        test_item.init_from_text(original_item)
        self.assertEqual(original_item, str(test_item))

        test_item.init_from_text(some_whitespace)
        self.assertEqual('x (B) This one is pretty weird', str(test_item))
Ejemplo n.º 7
0
    def test_init_from_text_priority(self):
        item_with_priority = '(A) This item is pretty important'
        item_with_priority2 = '(Z) Not so important'
        no_priority = 'Just some item'
        no_priority2 = '(b) Only caps should work here'

        test_item = TodoTxtItem()
        test_item.init_from_text(item_with_priority)
        self.assertEqual(test_item.priority, 'A')
        self.assertEqual(test_item.text, 'This item is pretty important')

        test_item.init_from_text(item_with_priority2)
        self.assertEqual(test_item.priority, 'Z')
        self.assertEqual(test_item.text, 'Not so important')

        test_item.init_from_text(no_priority)
        self.assertEqual(test_item.priority, None)
        self.assertEqual(test_item.text, 'Just some item')

        test_item.init_from_text(no_priority2)
        self.assertEqual(test_item.priority, None)
        self.assertEqual(test_item.text, '(b) Only caps should work here')
Ejemplo n.º 8
0
    def test_init_from_text_completion(self):
        completed_item = 'x This is a completed item'
        completed_whitespace = '    x Also completed    '
        not_completed = 'xNope, not even close'
        also_not_completed = '   Nope, not even close'

        test_item = TodoTxtItem()
        test_item.init_from_text(completed_item)
        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.text, 'This is a completed item')

        test_item.init_from_text(completed_whitespace)
        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.text, 'Also completed')

        test_item.init_from_text(not_completed)
        self.assertFalse(test_item.is_completed)
        self.assertEqual(test_item.text, 'xNope, not even close')

        test_item.init_from_text(also_not_completed)
        self.assertFalse(test_item.is_completed)
        self.assertEqual(test_item.text, 'Nope, not even close')
Ejemplo n.º 9
0
    def test_init_from_text_priority(self):
        item_with_priority = '(A) This item is pretty important'
        item_with_priority2 = '(Z) Not so important'
        no_priority = 'Just some item'
        no_priority2 = '(b) Only caps should work here'

        test_item = TodoTxtItem()
        test_item.init_from_text(item_with_priority)
        self.assertEqual(test_item.priority, 'A')
        self.assertEqual(test_item.text, 'This item is pretty important')

        test_item.init_from_text(item_with_priority2)
        self.assertEqual(test_item.priority, 'Z')
        self.assertEqual(test_item.text, 'Not so important')

        test_item.init_from_text(no_priority)
        self.assertEqual(test_item.priority, None)
        self.assertEqual(test_item.text, 'Just some item')

        test_item.init_from_text(no_priority2)
        self.assertEqual(test_item.priority, None)
        self.assertEqual(test_item.text, '(b) Only caps should work here')
Ejemplo n.º 10
0
    def test_init_from_text_completion(self):
        completed_item = 'x This is a completed item'
        completed_whitespace = '    x Also completed    '
        not_completed = 'xNope, not even close'
        also_not_completed = '   Nope, not even close'

        test_item = TodoTxtItem()
        test_item.init_from_text(completed_item)
        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.text, 'This is a completed item')

        test_item.init_from_text(completed_whitespace)
        self.assertTrue(test_item.is_completed)
        self.assertEqual(test_item.text, 'Also completed')

        test_item.init_from_text(not_completed)
        self.assertFalse(test_item.is_completed)
        self.assertEqual(test_item.text, 'xNope, not even close')

        test_item.init_from_text(also_not_completed)
        self.assertFalse(test_item.is_completed)
        self.assertEqual(test_item.text, 'Nope, not even close')