util: Convert '' value into None in tw_kwargs parser

This commit is contained in:
Tomas Babej 2015-03-28 03:02:52 +01:00
parent d9a0ef33d5
commit 4e782f1187
2 changed files with 4 additions and 1 deletions

View file

@ -76,7 +76,7 @@ def tw_modstring_to_kwargs(line):
# Ignore anything which is not one-word string of alpha chars
# This will skip over constructs with attribute modifiers
if key.isalpha():
output[key] = value
output[key] = value if value is not "" else None
# Tag addition
elif arg.startswith('+'):
value = arg[1:]

View file

@ -37,6 +37,9 @@ class TestParsingModstrings(object):
def test_modstring_to_kwargs_with_simple_tag(self):
assert util.tw_modstring_to_kwargs("+test ") == {"tags":["test"]}
def test_modstring_to_kwargs_with_removal(self):
assert util.tw_modstring_to_kwargs("project: +work") == {"tags":["work"], "project":None}
def test_modstring_to_kwargs_with_spaces(self):
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"]}