Ejemplo n.º 1
0
	def test_get_next_state_with_current_state_equals_todo_state(self):
		states = ['TODO', 'NEXT', 'NOW', 'DELEGATED', 'DONE']
		current_state = 'TODO'
		self.assertEquals(Todo._get_next_state(current_state, states), 'NEXT')

		current_state = 'NEXT'
		self.assertEquals(Todo._get_next_state(current_state, states), 'NOW')
Ejemplo n.º 2
0
    def test_todo_toggle_NOTODO(self):
        vim.current.window.cursor = (2, 0)
        vim.current.buffer[1] = u_encode(u'** NOTODO Überschrift 1.1')

        Todo.toggle_todo_state()
        self.assertEqual(vim.current.buffer[1],
                         u_encode(u'** TODO NOTODO Überschrift 1.1'))
Ejemplo n.º 3
0
	def test_get_next_state_with_current_state_equals_todo_state(self):
		states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
		current_state = u'TODO'
		self.assertEquals(Todo._get_next_state(current_state, states), u'NEXT')

		current_state = u'NEXT'
		self.assertEquals(Todo._get_next_state(current_state, states), u'NOW')
Ejemplo n.º 4
0
	def test_get_next_state_with_invalid_current_state(self):
		states = ['TODO', 'DONE']
		current_state = 'STI'
		self.assertEquals(Todo._get_next_state(current_state, states), 'TODO')

		states = ['TODO', 'NEXT', 'DELEGATED', 'DONE']
		self.assertEquals(Todo._get_next_state(current_state, states), 'TODO')
		states = ['NEXT', 'DELEGATED', 'DONE']
		self.assertEquals(Todo._get_next_state(current_state, states), 'NEXT')
Ejemplo n.º 5
0
	def test_toggle_todo_with_no_heading(self):
		# nothing should happen
		vim.current.window.cursor = (1, 0)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[0], u'')
		# and repeat it -> it should not change
		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[0], u'')
Ejemplo n.º 6
0
	def test_get_next_state_backward_with_no_current_state(self):
		states = [((u'TODO', ), (u'DONE', ))]
		current_state = u''
		self.assertEquals(Todo._get_next_state(current_state, states, False), u'DONE')

		states = [((u'TODO', u'NEXT'), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states, False), u'DONE')

		states = [((u'NEXT', ), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states, False), u'DONE')
Ejemplo n.º 7
0
	def test_get_next_state_with_invalid_current_state(self):
		states = [((u'TODO', ), (u'DONE', ))]
		current_state = u'STI'
		self.assertEquals(Todo._get_next_state(current_state, states), u'TODO')

		states = [((u'TODO', u'NEXT'), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states), u'TODO')

		states = [((u'NEXT', ), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states), u'NEXT')
Ejemplo n.º 8
0
	def test_get_next_state_backward_with_no_current_state(self):
		states = ['TODO', 'DONE']
		current_state = ''
		self.assertEquals(Todo._get_next_state(current_state, states, False), 'DONE')

		states = ['TODO', 'NEXT', 'DELEGATED', 'DONE']
		self.assertEquals(Todo._get_next_state(current_state, states, False), 'DONE')

		states = ['NEXT', 'DELEGATED', 'DONE']
		self.assertEquals(Todo._get_next_state(current_state, states, False), 'DONE')
Ejemplo n.º 9
0
	def test_get_next_state_backward_with_invalid_current_state(self):
		states = [((u'TODO', ), (u'DONE', ))]
		current_state = u'STI'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, u'DONE')

		states = [((u'TODO', u'NEXT'), (u'DELEGATED', u'DONE'))]
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, u'DONE')

		states = [((u'NEXT', ), (u'DELEGATED', u'DONE'))]
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, u'DONE')
Ejemplo n.º 10
0
    def test_get_next_state_backward_with_invalid_current_state(self):
        states = [((u'TODO', ), (u'DONE', ))]
        current_state = u'STI'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DONE')

        states = [((u'TODO', u'NEXT'), (u'DELEGATED', u'DONE'))]
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DONE')

        states = [((u'NEXT', ), (u'DELEGATED', u'DONE'))]
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DONE')
Ejemplo n.º 11
0
	def test_get_next_state_backward_with_invalid_current_state(self):
		states = ['TODO', 'DONE']
		current_state = 'STI'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'DONE')

		states = ['TODO', 'NEXT', 'DELEGATED', 'DONE']
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'DONE')

		states = ['NEXT', 'DELEGATED', 'DONE']
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'DONE')
Ejemplo n.º 12
0
	def test_get_next_state_backward_with_no_current_state(self):
		states = [((u'TODO', ), (u'DONE', ))]
		current_state = u''
		self.assertEquals(Todo._get_next_state(current_state, states,
				Direction.BACKWARD), u'DONE')

		states = [((u'TODO', u'NEXT'), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states,
				Direction.BACKWARD), u'DONE')

		states = [((u'NEXT', ), (u'DELEGATED', u'DONE'))]
		self.assertEquals(Todo._get_next_state(current_state, states,
				Direction.BACKWARD), u'DONE')
Ejemplo n.º 13
0
	def test_get_next_keyword_sequence(self):
		states = [((u'TODO(t)', u'NEXT(n)', u'NOW(w)'), (u'DELEGATED(g)', u'DONE(d)')), ((u'QA(q)', ), (u'RELEASED(r)', ))]
		current_state = None
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'TODO')

		current_state = None
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD, next_set=True)
		self.assertEquals(result, None)

		current_state = u'TODO'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD, next_set=True)
		self.assertEquals(result, u'TODO')

		current_state = u'TODO'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'QA')

		current_state = u'NOW'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'QA')

		current_state = u'DELEGATED'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'QA')

		current_state = u'QA'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD, next_set=True)
		self.assertEquals(result, u'TODO')

		current_state = u'QA'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'QA')

		current_state = u'RELEASED'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD, next_set=True)
		self.assertEquals(result, u'RELEASED')

		current_state = u'RELEASED'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD, next_set=True)
		self.assertEquals(result, u'TODO')
Ejemplo n.º 14
0
    def test_circle_through_todo_states_with_more_states(self):
        # * Heading 1 -->
        # * TODO Heading 1 -->
        # * STARTED Heading 1 -->
        # * DONE Heading 1 -->
        # * Heading 1 -->
        vim.EVALRESULTS[u_encode(u'g:org_todo_keywords')] = [
            u_encode(u'TODO'),
            u_encode(u'STARTED'),
            u_encode(u'DONE'),
            u_encode(u'|')
        ]
        vim.current.window.cursor = (2, 0)

        Todo.toggle_todo_state()
        self.assertEqual(vim.current.buffer[1], u'* TODO Heading 1')

        Todo.toggle_todo_state()
        self.assertEqual(vim.current.buffer[1], u'* STARTED Heading 1')

        Todo.toggle_todo_state()
        self.assertEqual(vim.current.buffer[1], u'* DONE Heading 1')

        Todo.toggle_todo_state()
        self.assertEqual(vim.current.buffer[1], u'* Heading 1')
Ejemplo n.º 15
0
 def test_get_next_state_backward_with_current_state_equals_todo_state(
         self):
     states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
     current_state = u'TODO'
     result = Todo._get_next_state(current_state, states,
                                   Direction.BACKWARD)
     self.assertEquals(result, None)
Ejemplo n.º 16
0
	def test_get_next_state_in_current_sequence_with_access_keys(self):
		states = [((u'TODO(t)', u'NEXT(n)', u'NOW(w)'), (u'DELEGATED(g)', u'DONE(d)')), ((u'QA(q)', ), (u'RELEASED(r)', ))]
		current_state = u'QA'
		result = Todo._get_next_state(current_state, states, True)
		self.assertEquals(result, u'RELEASED')

		current_state = u'NEXT'
		result = Todo._get_next_state(current_state, states, True)
		self.assertEquals(result, u'NOW')

		current_state = u'TODO'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, None)

		current_state = None
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, u'DONE')
Ejemplo n.º 17
0
    def test_get_next_state_in_current_sequence_with_access_keys(self):
        states = [((u'TODO(t)', u'NEXT(n)', u'NOW(w)'), (u'DELEGATED(g)',
                                                         u'DONE(d)')),
                  ((u'QA(q)', ), (u'RELEASED(r)', ))]
        current_state = u'QA'
        result = Todo._get_next_state(current_state, states, True)
        self.assertEquals(result, u'RELEASED')

        current_state = u'NEXT'
        result = Todo._get_next_state(current_state, states, True)
        self.assertEquals(result, u'NOW')

        current_state = u'TODO'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, None)

        current_state = None
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DONE')
Ejemplo n.º 18
0
	def test_get_next_state_backward_misc(self):
		states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
		current_state = u'DONE'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, u'DELEGATED')

		current_state = u'DELEGATED'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, u'NOW')

		current_state = u'NOW'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, u'NEXT')

		current_state = u'NEXT'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, u'TODO')

		current_state = u'TODO'
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, None)

		current_state = None
		result = Todo._get_next_state(current_state, states,
				Direction.BACKWARD)
		self.assertEquals(result, u'DONE')
Ejemplo n.º 19
0
    def test_get_next_state_backward_misc(self):
        states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
        current_state = u'DONE'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DELEGATED')

        current_state = u'DELEGATED'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'NOW')

        current_state = u'NOW'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'NEXT')

        current_state = u'NEXT'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'TODO')

        current_state = u'TODO'
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, None)

        current_state = None
        result = Todo._get_next_state(current_state, states, False)
        self.assertEquals(result, u'DONE')
Ejemplo n.º 20
0
	def test_get_next_state_backward_misc(self):
		states = ['TODO', 'NEXT', 'NOW', 'DELEGATED', 'DONE']
		current_state = 'DONE'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'DELEGATED')

		current_state = 'DELEGATED'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'NOW')

		current_state = 'NOW'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'NEXT')

		current_state = 'NEXT'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'TODO')

		current_state = 'TODO'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, None)

		current_state = None
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, 'DONE')
Ejemplo n.º 21
0
	def test_get_current_state(self):
		states = ['TODO', 'INPROGRESS', 'DUMMY', 'DONE']

		heading_text = ''
		expected = None, ''
		result = Todo._split_heading(heading_text, states)
		self.assertEqual(result, expected)

		heading_text = None
		expected = None, ''
		result = Todo._split_heading(heading_text, states)
		self.assertEqual(result, expected)

		heading_text = 'Heading asdf'
		expected = (None, heading_text)
		result = Todo._split_heading(heading_text, states)
		self.assertEqual(result, expected)

		heading_text = 'TODO Heaging asdf'
		expected = 'TODO', 'Heaging asdf'
		result = Todo._split_heading(heading_text, states)
		self.assertEqual(result, expected)
Ejemplo n.º 22
0
	def test_get_states_without_seperator(self):
		"""The last element in the todostates shouold be used as DONE-state when no sperator is given"""
		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo, expected_done = ['TODO'], ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'INPROGRESS', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo = ['TODO', 'INPROGRESS']
		expected_done = ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'INPROGRESS',
				'DUMMY', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo  = ['TODO', 'INPROGRESS', 'DUMMY']
		expected_done = ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)
Ejemplo n.º 23
0
	def test_get_states_with_seperator(self):
		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', '|', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo = ['TODO']
		expected_done = ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'INPROGRESS', '|',
				'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo = ['TODO', 'INPROGRESS']
		expected_done = ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'INPROGRESS',
				'DUMMY', '|',  'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo = ['TODO', 'INPROGRESS', 'DUMMY']
		expected_done = ['DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', 'INPROGRESS',
				'DUMMY', '|', 'DELEGATED', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo =['TODO', 'INPROGRESS', 'DUMMY']
		expected_done = ['DELEGATED', 'DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)

		vim.EVALRESULTS['g:org_todo_keywords'] = ['TODO', '|', 'DONEX',
				'DUMMY', 'DELEGATED', 'DONE']
		states_todo, states_done = Todo._get_states()
		expected_todo = ['TODO']
		expected_done = ['DONEX', 'DUMMY', 'DELEGATED', 'DONE']
		self.assertEqual(states_todo, expected_todo)
		self.assertEqual(states_done, expected_done)
Ejemplo n.º 24
0
	def test_circle_through_todo_states_with_more_states(self):
		# * Heading 1 -->
		# * TODO Heading 1 -->
		# * STARTED Heading 1 -->
		# * DONE Heading 1 -->
		# * Heading 1 -->
		vim.EVALRESULTS[u_encode(u'g:org_todo_keywords')] = [u_encode(u'TODO'), u_encode(u'STARTED'), u_encode(u'DONE'),
				u_encode(u'|')]
		vim.current.window.cursor = (2, 0)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* TODO Heading 1')

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* STARTED Heading 1')

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* DONE Heading 1')

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* Heading 1')
Ejemplo n.º 25
0
	def test_toggle_todo_with_cursor_in_text_not_heading(self):
		# nothing should happen
		vim.current.window.cursor = (7, 0)
		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[5], u'** TODO Text 1')
		self.assertEqual(vim.current.window.cursor, (7, 0))

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[5], u'** DONE Text 1')
		self.assertEqual(vim.current.window.cursor, (7, 0))

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[5], u'** Text 1')
		self.assertEqual(vim.current.window.cursor, (7, 0))
Ejemplo n.º 26
0
	def test_toggle_todo_in_heading_with_no_todo_state_different_levels(self):
		# level 1
		vim.current.window.cursor = (2, 0)
		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* TODO Heading 1')
		self.assertEqual((2, 0), vim.current.window.cursor)

		# level 2
		vim.current.window.cursor = (3, 0)
		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[2], u'** TODO Text 1')

		# level 2
		vim.current.window.cursor = (4, 4)
		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[3], u'*** TODO Text 2')
		self.assertEqual((4, 9), vim.current.window.cursor)
Ejemplo n.º 27
0
	def test_circle_through_todo_states(self):
		# * Heading 1 -->
		# * TODO Heading 1 -->
		# * DONE Heading 1 -->
		# * Heading 1 -->
		# * TODO Heading 1 -->
		# * DONE Heading 1
		vim.current.window.cursor = (2, 6)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* TODO Heading 1')
		self.assertEqual((2, 11), vim.current.window.cursor)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* DONE Heading 1')
		self.assertEqual((2, 11), vim.current.window.cursor)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* Heading 1')
		self.assertEqual((2, 6), vim.current.window.cursor)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* TODO Heading 1')
		self.assertEqual((2, 11), vim.current.window.cursor)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* DONE Heading 1')
		self.assertEqual((2, 11), vim.current.window.cursor)

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u'* Heading 1')
		self.assertEqual((2, 6), vim.current.window.cursor)
Ejemplo n.º 28
0
	def test_todo_toggle_NOTODO(self):
		vim.current.window.cursor = (2, 0)
		vim.current.buffer[1] = u_encode(u'** NOTODO Überschrift 1.1')

		Todo.toggle_todo_state()
		self.assertEqual(vim.current.buffer[1], u_encode(u'** TODO NOTODO Überschrift 1.1'))
Ejemplo n.º 29
0
	def test_get_next_state_with_jump_from_todo_to_done(self):
		states = ['TODO', 'NEXT', 'NOW', 'DELEGATED', 'DONE']
		current_state = 'NOW'
		self.assertEquals(Todo._get_next_state(current_state, states), 'DELEGATED')
Ejemplo n.º 30
0
	def test_get_next_state_backward_with_current_state_equals_todo_state(self):
		states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
		current_state = u'TODO'
		result = Todo._get_next_state(current_state, states, False)
		self.assertEquals(result, None)
Ejemplo n.º 31
0
	def test_get_next_state_in_current_sequence(self):
		states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE')), ((u'QA', ), (u'RELEASED', ))]
		current_state = u'QA'
		result = Todo._get_next_state(current_state, states,
				Direction.FORWARD)
		self.assertEquals(result, u'RELEASED')
Ejemplo n.º 32
0
	def test_get_next_state_with_jump_from_done_to_todo(self):
		states = [((u'TODO', u'NEXT', u'NOW'), (u'DELEGATED', u'DONE'))]
		current_state = u'DONE'
		self.assertEquals(Todo._get_next_state(current_state, states), None)