tests: Add simple test for monthly ghistory

This commit is contained in:
Tomas Babej 2015-03-27 13:36:44 +01:00
parent 451a0773da
commit 9a3a619791

View file

@ -41,7 +41,7 @@ class TestCalendarSimple(IntegrationTest):
assert any(day in line for line in output) assert any(day in line for line in output)
class TestGhistorySimple(IntegrationTest): class TestGhistoryAnnualSimple(IntegrationTest):
tasks = [ tasks = [
dict(description="test task"), dict(description="test task"),
@ -65,3 +65,35 @@ class TestGhistorySimple(IntegrationTest):
current_year = local_zone.localize(datetime.now()).year current_year = local_zone.localize(datetime.now()).year
assert str(current_year) in '\n'.join(output) assert str(current_year) in '\n'.join(output)
class TestGhistoryMonthlySimple(IntegrationTest):
tasks = [
dict(description="test task"),
dict(description="completed task 1", status="completed", end="now"),
dict(description="completed task 2", status="completed", end="now"),
dict(description="deleted task", status="deleted"),
]
def execute(self):
self.command("TaskWikiGhistoryMonthly")
assert self.command(":py print vim.current.buffer", silent=False).startswith("<buffer ghistory.monthly")
output = self.read_buffer()
header_words = ("Year", "Month", "Number", "Added", "Completed", "Deleted")
for word in header_words:
assert word in output[0]
legend_words = ("Legend", "Added", "Completed", "Deleted")
for word in legend_words:
assert re.search(word, output[-1], re.IGNORECASE)
current_year = local_zone.localize(datetime.now()).year
current_month_number = local_zone.localize(datetime.now()).month
months = ["January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"]
assert str(current_year) in '\n'.join(output)
assert str(months[current_month_number - 1]) in '\n'.join(output)