Implemented multi-markup parsing tests for viewport and preset

This commit is contained in:
DancingQuanta 2018-09-09 18:11:18 +01:00 committed by Tomas Babej
parent 920c065d98
commit 159d5c4b79
2 changed files with 69 additions and 40 deletions

View file

@ -16,16 +16,31 @@ class TestParsingPresetHeader(object):
self.mockvim.reset()
self.cache.reset()
def test_simple(self):
self.cache.buffer[0] = "== Test || project:Home =="
def process_preset_header(self, preset_header, test_syntax):
"""
Expands the example preset_header to a syntax of a markup and pass on to
MockVim to be processed.
The result of the processed preset_header is collected.
"""
markup, header_expand = test_syntax
formatted_preset_header = header_expand(preset_header)
print(formatted_preset_header)
self.cache.markup_syntax = markup
self.cache.buffer[0] = formatted_preset_header
header = self.PresetHeader.from_line(0, self.cache)
return header
def test_simple(self, test_syntax):
preset_header = "HEADER2(Test || project:Home)"
header = self.process_preset_header(preset_header, test_syntax)
assert header.taskfilter == ["(", "project:Home", ")"]
assert header.defaults == {'project': 'Home'}
def test_defaults(self):
self.cache.buffer[0] = "== Test || project:Home || +home =="
header = self.PresetHeader.from_line(0, self.cache)
def test_defaults(self, test_syntax):
preset_header = "HEADER2(Test || project:Home || +home)"
header = self.process_preset_header(preset_header, test_syntax)
assert header.taskfilter == ["(", "project:Home", ")"]
assert header.defaults == {'tags': ['home']}