Add unit tests for default, suppressed and custom mappings

This commit is contained in:
mrossinek 2019-02-23 11:18:50 +01:00 committed by Tomas Babej
parent c5310126fa
commit 504aefadef
No known key found for this signature in database
GPG key ID: B0747C6578F7D2F5

122
tests/test_mappings.py Normal file
View file

@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
from tests.base import IntegrationTest
from time import sleep
class TestDefaultMapping(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
vimoutput = """
* [X] test task 1 #{uuid}
* [X] test task 2 #{uuid}
"""
tasks = [
dict(description="test task 1"),
dict(description="test task 2"),
]
def execute(self):
self.client.normal('1gg')
sleep(0.5)
self.client.feedkeys(r'\\td')
sleep(0.5)
self.client.normal('2gg')
sleep(0.5)
self.client.normal('V')
sleep(0.5)
self.client.feedkeys(r'\\td')
sleep(0.5)
for task in self.tasks:
task.refresh()
class TestSuppressedMapping(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
vimoutput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
tasks = [
dict(description="test task 1"),
dict(description="test task 2"),
]
def configure_global_varialbes(self):
super(TestSuppressedMapping, self).configure_global_varialbes()
self.command('let g:taskwiki_suppress_mappings="yes"')
def execute(self):
self.client.normal('1gg')
sleep(0.5)
self.client.feedkeys(r'\\td')
sleep(0.5)
self.client.normal('2gg')
sleep(0.5)
self.client.normal('V')
sleep(0.5)
self.client.feedkeys(r'\\td')
sleep(0.5)
for task in self.tasks:
task.refresh()
class TestCustomMapping(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
vimoutput = """
* [X] test task 1 #{uuid}
* [X] test task 2 #{uuid}
"""
tasks = [
dict(description="test task 1"),
dict(description="test task 2"),
]
def configure_global_varialbes(self):
super(TestCustomMapping, self).configure_global_varialbes()
self.command('let g:taskwiki_maplocalleader=",t"')
def execute(self):
self.client.normal('1gg')
sleep(0.5)
self.client.feedkeys(',td')
sleep(0.5)
self.client.normal('2gg')
sleep(0.5)
self.client.normal('V')
sleep(0.5)
self.client.feedkeys(',td')
sleep(0.5)
for task in self.tasks:
task.refresh()