def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()

        # Setup fake entries for custom TaskWarrior instance and Sort order
        self.cache.warriors.update({'T': 'extra'})
        self.mockvim.vars.update({'taskwiki_sort_orders': dict(T='extra')})

        sys.modules['vim'] = self.mockvim
        from taskwiki.viewport import ViewPort
        self.ViewPort = ViewPort
Example #2
0
    def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()

        # Setup fake entries for custom TaskWarrior instance and Sort order
        self.cache.warriors.update({'T': 'extra'})
        self.mockvim.vars.update({'taskwiki_sort_orders': dict(T='extra')})

        sys.modules['vim'] = self.mockvim
        from taskwiki.viewport import ViewPort
        self.ViewPort = ViewPort
Example #3
0
class TestParsingVimwikiTask(object):
    def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()

        # Setup fake entries for custom TaskWarrior instance and Sort order
        self.cache.warriors.update({'T': 'extra'})
        self.mockvim.vars.update({'taskwiki_sort_orders': dict(T='extra')})

        sys.modules['vim'] = self.mockvim
        from taskwiki.viewport import ViewPort
        self.ViewPort = ViewPort

    def teardown(self):
        self.mockvim.reset()
        self.cache.reset()

    def test_simple(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_defaults(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home | +home =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'tags':['home']}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_different_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home #T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'extra'

    def test_different_sort(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'default'

    def test_different_sort_with_complex_filter(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home or project:Work $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home", "or", "project:Work"]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'default'

    def test_different_sort_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home #T $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'extra'

    def test_defaults_different_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home | +home #T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'tags':['home']}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'extra'

    def test_defaults_different_tw_sort(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home | +home #T $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + ["project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'tags':['home']}
        assert port.sort == 'extra'
        assert port.tw == 'extra'

    def test_override_default_virtual_tags_neutral(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !?DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-PARENT", "project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project':'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_positive(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !+DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["+DELETED", "-PARENT", "project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project':'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_negative(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !-DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-DELETED", "-PARENT","project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project':'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_positive_without_forcing(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home +DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-PARENT", "project:Home", "+DELETED"]
        assert port.name == "Test"
        assert port.defaults == {'project':'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'
Example #4
0
 def setup(self):
     self.mockvim = MockVim()
     self.cache = MockCache()
     sys.modules['vim'] = self.mockvim
     from taskwiki.vwtask import VimwikiTask
     self.VimwikiTask = VimwikiTask
class TestParsingVimwikiTask(object):
    def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()

        # Setup fake entries for custom TaskWarrior instance and Sort order
        self.cache.warriors.update({'T': 'extra'})
        self.mockvim.vars.update({'taskwiki_sort_orders': dict(T='extra')})

        sys.modules['vim'] = self.mockvim
        from taskwiki.viewport import ViewPort
        self.ViewPort = ViewPort

    def teardown(self):
        self.mockvim.reset()
        self.cache.reset()

    def test_simple(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_defaults(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home | +home =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.defaults == {'tags': ['home']}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_different_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home #T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'extra'

    def test_different_sort(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'default'

    def test_different_sort_with_complex_filter(self):
        self.mockvim.current.buffer[
            0] = "== Test | project:Home or project:Work $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home", "or", "project:Work"
        ]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'default'

    def test_different_sort_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home #T $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.sort == 'extra'
        assert port.tw == 'extra'

    def test_defaults_different_tw(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home | +home #T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.defaults == {'tags': ['home']}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'extra'

    def test_defaults_different_tw_sort(self):
        self.mockvim.current.buffer[
            0] = "== Test | project:Home | +home #T $T =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == list(DEFAULT_VIEWPORT_VIRTUAL_TAGS) + [
            "project:Home"
        ]
        assert port.name == "Test"
        assert port.defaults == {'tags': ['home']}
        assert port.sort == 'extra'
        assert port.tw == 'extra'

    def test_override_default_virtual_tags_neutral(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !?DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-PARENT", "project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project': 'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_positive(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !+DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["+DELETED", "-PARENT", "project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project': 'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_negative(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home !-DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-DELETED", "-PARENT", "project:Home"]
        assert port.name == "Test"
        assert port.defaults == {'project': 'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'

    def test_override_default_virtual_tags_positive_without_forcing(self):
        self.mockvim.current.buffer[0] = "== Test | project:Home +DELETED =="
        port = self.ViewPort.from_line(0, self.cache)

        assert port.taskfilter == ["-PARENT", "project:Home", "+DELETED"]
        assert port.name == "Test"
        assert port.defaults == {'project': 'Home'}
        assert port.sort == DEFAULT_SORT_ORDER
        assert port.tw == 'default'
Example #6
0
class TestParsingVimwikiTask(object):
    def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()
        sys.modules['vim'] = self.mockvim
        from taskwiki.vwtask import VimwikiTask
        self.VimwikiTask = VimwikiTask

    def teardown(self):
        self.mockvim.reset()
        self.cache.reset()

    def test_simple(self):
        self.mockvim.current.buffer[0] = "* [ ] This is task description"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == "This is task description"
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['indent'] == ''

    def test_simple_with_unicode(self):
        self.mockvim.current.buffer[0] = "* [ ] This is täsk description"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"This is täsk description"
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['indent'] == ''

    def test_due_full(self):
        self.mockvim.current.buffer[0] = "* [ ] Random task (2015-08-08 15:15)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Random task"
        assert vwtask['due'] == local_zone.localize(
            datetime(2015, 8, 8, 15, 15))
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['indent'] == ''

    def test_due_short(self):
        self.mockvim.current.buffer[0] = "* [ ] Random task (2015-08-08)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Random task"
        assert vwtask['due'] == local_zone.localize(datetime(2015, 8, 8, 0, 0))
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['indent'] == ''

    def test_priority_low(self):
        self.mockvim.current.buffer[0] = "* [ ] Semi-Important task !"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Semi-Important task"
        assert vwtask['priority'] == 'L'
        assert vwtask['uuid'] == None

    def test_priority_medium(self):
        self.mockvim.current.buffer[0] = "* [ ] Important task !!"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Important task"
        assert vwtask['priority'] == 'M'
        assert vwtask['uuid'] == None

    def test_priority_high(self):
        self.mockvim.current.buffer[0] = "* [ ] Very important task !!!"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Very important task"
        assert vwtask['priority'] == 'H'
        assert vwtask['uuid'] == None
        assert vwtask['due'] == None

    def test_priority_and_due(self):
        self.mockvim.current.buffer[0] = "* [ ] Due today !!! (2015-08-08)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Due today"
        assert vwtask['priority'] == 'H'
        assert vwtask['due'] == local_zone.localize(datetime(2015, 8, 8))
        assert vwtask['uuid'] == None

    def test_added_modstring(self):
        self.mockvim.current.buffer[0] = "* [ ] Home task -- project:Home"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Home task"
        assert vwtask['project'] == u"Home"
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['uuid'] == None
Example #7
0
 def setup(self):
     self.mockvim = MockVim()
     self.cache = MockCache()
     sys.modules['vim'] = self.mockvim
     from taskwiki.vwtask import VimwikiTask
     self.VimwikiTask = VimwikiTask
Example #8
0
class TestParsingVimwikiTask(object):
    def setup(self):
        self.mockvim = MockVim()
        self.cache = MockCache()
        sys.modules['vim'] = self.mockvim
        from taskwiki.vwtask import VimwikiTask
        self.VimwikiTask = VimwikiTask

    def teardown(self):
        self.mockvim.reset()
        self.cache.reset()

    def test_simple(self):
        self.mockvim.current.buffer[0] = "* [ ] This is task description"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == "This is task description"
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['indent'] == ''

    def test_simple_with_unicode(self):
        self.mockvim.current.buffer[0] = "* [ ] This is täsk description"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"This is täsk description"
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['indent'] == ''

    def test_due_full(self):
        self.mockvim.current.buffer[0] = "* [ ] Random task (2015-08-08 15:15)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Random task"
        assert vwtask['due'] == local_zone.localize(datetime(2015,8,8,15,15))
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['indent'] == ''

    def test_due_short(self):
        self.mockvim.current.buffer[0] = "* [ ] Random task (2015-08-08)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Random task"
        assert vwtask['due'] == local_zone.localize(datetime(2015,8,8,0,0))
        assert vwtask['uuid'] == None
        assert vwtask['priority'] == None
        assert vwtask['indent'] == ''

    def test_priority_low(self):
        self.mockvim.current.buffer[0] = "* [ ] Semi-Important task !"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Semi-Important task"
        assert vwtask['priority'] == 'L'
        assert vwtask['uuid'] == None

    def test_priority_medium(self):
        self.mockvim.current.buffer[0] = "* [ ] Important task !!"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Important task"
        assert vwtask['priority'] == 'M'
        assert vwtask['uuid'] == None

    def test_priority_high(self):
        self.mockvim.current.buffer[0] = "* [ ] Very important task !!!"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Very important task"
        assert vwtask['priority'] == 'H'
        assert vwtask['uuid'] == None
        assert vwtask['due'] == None

    def test_priority_and_due(self):
        self.mockvim.current.buffer[0] = "* [ ] Due today !!! (2015-08-08)"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Due today"
        assert vwtask['priority'] == 'H'
        assert vwtask['due'] == local_zone.localize(datetime(2015,8,8))
        assert vwtask['uuid'] == None

    def test_added_modstring(self):
        self.mockvim.current.buffer[0] = "* [ ] Home task -- project:Home"
        vwtask = self.VimwikiTask.from_line(self.cache, 0)

        assert vwtask['description'] == u"Home task"
        assert vwtask['project'] == u"Home"
        assert vwtask['priority'] == None
        assert vwtask['due'] == None
        assert vwtask['uuid'] == None