mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
tests: Add tests for util
This commit is contained in:
parent
31d5b718c1
commit
22172e7ae3
2 changed files with 32 additions and 0 deletions
5
tests/__init__.py
Normal file
5
tests/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
sys.path.insert(0, path)
|
27
tests/test_util.py
Normal file
27
tests/test_util.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Mock vim to test vim-nonrelated functions
|
||||||
|
class MockVim(object):
|
||||||
|
|
||||||
|
def eval(*args, **kwargs):
|
||||||
|
return 42
|
||||||
|
|
||||||
|
sys.modules['vim'] = MockVim()
|
||||||
|
|
||||||
|
from taskwiki import util
|
||||||
|
|
||||||
|
def test_modstring_to_args():
|
||||||
|
assert util.tw_modstring_to_args("") == []
|
||||||
|
assert util.tw_modstring_to_args("project:Random") == ["project:Random"]
|
||||||
|
assert util.tw_modstring_to_args("project:Random area:admin") == ["project:Random", "area:admin"]
|
||||||
|
assert util.tw_modstring_to_args("project:Random +test") == ["project:Random", "+test"]
|
||||||
|
assert util.tw_modstring_to_args("project:'Random +test'") == ["project:Random +test"]
|
||||||
|
|
||||||
|
def test_modstring_to_kwargs():
|
||||||
|
assert util.tw_modstring_to_kwargs("") == {}
|
||||||
|
assert util.tw_modstring_to_kwargs("project:Random") == {"project":"Random"}
|
||||||
|
assert util.tw_modstring_to_kwargs("project:Random area:admin") == {"project":"Random", "area":"admin"}
|
||||||
|
assert util.tw_modstring_to_kwargs("project:Random +test") == {"project":"Random", "tags":["test"]}
|
||||||
|
assert util.tw_modstring_to_kwargs("project:Random +test +home") == {"project":"Random", "tags":["test", "home"]}
|
||||||
|
assert util.tw_modstring_to_kwargs("project:'Random +test'") == {"project":"Random +test"}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue