tests: Expand test coverage

This commit is contained in:
Tomas Babej 2015-12-27 12:41:36 +01:00
parent 38ae7730fa
commit f96c810ffb
4 changed files with 186 additions and 1 deletions

View file

@ -179,5 +179,43 @@ class TestChooseTagCancelled(IntegrationTest):
task.refresh()
assert self.tasks[0]['tags'] == set(["home"])
assert self.tasks[1]['project'] == None
assert self.tasks[1]['tags'] == set()
class TestChooseTagNoSelected(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
vimoutput = """
Tag Count
---- -----
home 1
"""
tasks = [
dict(description="test task 1", tags=["home"]),
dict(description="test task 2"),
]
def execute(self):
self.client.normal('1gg')
sleep(0.5)
self.command("TaskWikiChooseTag")
sleep(0.5)
# No tak on the 5th row
self.client.normal('5gg')
sleep(0.5)
self.client.feedkeys("\\<CR>")
sleep(0.5)
for task in self.tasks:
task.refresh()
assert self.tasks[0]['tags'] == set(["home"])
assert self.tasks[1]['tags'] == set()

View file

@ -259,6 +259,35 @@ class TestInfoAction(IntegrationTest):
assert re.search(data2, output, re.MULTILINE)
class TestInfoActionTriggeredByEnter(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
tasks = [
dict(description="test task 1"),
dict(description="test task 2"),
]
def execute(self):
self.client.type('1gg')
self.client.feedkeys("\\<CR>")
sleep(0.5)
assert self.command(":py print vim.current.buffer", silent=False).startswith("<buffer info")
output = '\n'.join(self.read_buffer())
header = r'\s*'.join(['Name', 'Value'])
data = r'\s*'.join(['Description', 'test task 1'])
data2 = r'\s*'.join(['Status', 'Pending'])
assert re.search(header, output, re.MULTILINE)
assert re.search(data, output, re.MULTILINE)
assert re.search(data2, output, re.MULTILINE)
class TestInfoActionMoved(IntegrationTest):
viminput = """
@ -832,6 +861,35 @@ class TestDoneAction(IntegrationTest):
assert self.tasks[1]['end'] == None
class TestDoneNoSelected(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 execute(self):
self.client.type('2gg')
self.command(
"TaskWikiDone",
regex="No tasks selected.",
lines=1)
assert self.tasks[0]['status'] == "pending"
assert self.tasks[1]['status'] == "pending"
class TestDoneActionMoved(IntegrationTest):
@ -911,3 +969,30 @@ class TestDoneActionRange(IntegrationTest):
assert (now - self.tasks[1]['end']).total_seconds() < 5
assert (self.tasks[1]['end'] - now).total_seconds() < 5
class TestSortManually(IntegrationTest):
viminput = """
* [ ] test task 1 #{uuid}
* [ ] test task 2 #{uuid}
"""
vimoutput = """
* [ ] test task 2 #{uuid}
* [ ] test task 1 #{uuid}
"""
tasks = [
dict(description="test task 1"),
dict(description="test task 2"),
]
def execute(self):
self.client.normal('1gg')
sleep(0.5)
self.client.normal('VG')
sleep(0.5)
self.client.feedkeys(":TaskWikiSort description-")
self.client.type("<Enter>")
sleep(0.5)

View file

@ -246,6 +246,30 @@ class TestTagsSimple(IntegrationTest):
assert re.search(work, output, re.MULTILINE)
class TestTagsSimpleFiltered(IntegrationTest):
tasks = [
dict(description="home task"),
dict(description="home chore task 1", tags=['chore']),
dict(description="home chore task 2", tags=['chore']),
dict(description="work task 1", tags=['work']),
dict(description="work task 2", tags=['work']),
]
def execute(self):
self.command("TaskWikiTags +chore")
assert self.command(":py print vim.current.buffer", silent=False).startswith("<buffer tags")
output = '\n'.join(self.read_buffer())
header = r'\s*'.join(['Tag', 'Count'])
chores = r'\s*'.join(['chore', '2'])
work = r'\s*'.join(['work', '2'])
assert re.search(header, output, re.MULTILINE)
assert re.search(chores, output, re.MULTILINE)
assert not re.search(work, output, re.MULTILINE)
class TestSplitReplacement(IntegrationTest):
def execute(self):

View file

@ -227,6 +227,44 @@ class TestViewportInspection(IntegrationTest):
assert self.command(":py print vim.current.buffer", regex="<buffer taskwiki.")
class TestViewportInspectionWithVisibleTag(IntegrationTest):
viminput = """
=== Work tasks | +work -VISIBLE ===
* [ ] tag work task #{uuid}
=== Home tasks | +home ===
* [ ] tag work task #{uuid}
"""
vimoutput = """
ViewPort inspection:
--------------------
Name: Work tasks
Filter used: -DELETED -PARENT +work
Defaults used: tags:['work']
Ordering used: due+,pri-,project+
Matching taskwarrior tasks: 0
Displayed tasks: 0
Tasks to be added:
Tasks to be deleted:
"""
tasks = [
dict(description="tag work task", tags=['work', 'home']),
]
def execute(self):
self.command("w", regex="written$", lines=1)
sleep(0.5)
self.client.feedkeys('1gg')
sleep(0.5)
self.client.feedkeys(r'\<CR>')
sleep(0.5)
assert self.command(":py print vim.current.buffer", regex="<buffer taskwiki.")
class TestViewportsUnicodeTaskGeneration(IntegrationTest):
viminput = """