Commit 59452903 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Properly deal with integers passed as expression.

parent 37aba451
...@@ -186,6 +186,13 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -186,6 +186,13 @@ class FilterTest(TopydoTest.TopydoTest):
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter19(self): def test_filter19(self):
todos = load_file('test/data/FilterTest1.txt')
grep = Filter.GrepFilter(1)
filtered_todos = grep.filter(todos)
self.assertEquals(filtered_todos, [])
def test_filter20(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:<2014-11-10') otf = Filter.OrdinalTagFilter('due:<2014-11-10')
...@@ -195,7 +202,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -195,7 +202,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), \ self.assertEquals(todolist_to_string(filtered_todos), \
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter20(self): def test_filter21(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10') otf = Filter.OrdinalTagFilter('due:=2014-11-10')
...@@ -203,7 +210,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -203,7 +210,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter21(self): def test_filter22(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10') otf = Filter.OrdinalTagFilter('due:=2014-11-10')
...@@ -211,7 +218,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -211,7 +218,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter22(self): def test_filter23(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-99') otf = Filter.OrdinalTagFilter('due:=2014-11-99')
...@@ -219,7 +226,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -219,7 +226,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter23(self): def test_filter24(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=garbage') otf = Filter.OrdinalTagFilter('due:=garbage')
...@@ -227,7 +234,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -227,7 +234,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter24(self): def test_filter25(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<10') otf = Filter.OrdinalTagFilter('value:<10')
...@@ -237,7 +244,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -237,7 +244,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter25(self): def test_filter26(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<=16') otf = Filter.OrdinalTagFilter('value:<=16')
...@@ -247,7 +254,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -247,7 +254,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter26(self): def test_filter27(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16') otf = Filter.OrdinalTagFilter('value:<16')
...@@ -257,7 +264,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -257,7 +264,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter27(self): def test_filter28(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16a') otf = Filter.OrdinalTagFilter('value:<16a')
...@@ -265,7 +272,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -265,7 +272,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter28(self): def test_filter29(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>8') otf = Filter.OrdinalTagFilter('value:>8')
...@@ -275,7 +282,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -275,7 +282,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter29(self): def test_filter30(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>=8') otf = Filter.OrdinalTagFilter('value:>=8')
...@@ -285,7 +292,7 @@ class FilterTest(TopydoTest.TopydoTest): ...@@ -285,7 +292,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter30(self): def test_filter31(self):
todos = load_file('test/data/FilterTest3.txt') todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>-8') otf = Filter.OrdinalTagFilter('value:>-8')
......
...@@ -62,7 +62,8 @@ class GrepFilter(Filter): ...@@ -62,7 +62,8 @@ class GrepFilter(Filter):
def __init__(self, p_expression, p_case_sensitive=None): def __init__(self, p_expression, p_case_sensitive=None):
super(GrepFilter, self).__init__() super(GrepFilter, self).__init__()
self.expression = p_expression # convert to string in case we receive integers
self.expression = str(p_expression)
if p_case_sensitive != None: if p_case_sensitive != None:
self.case_sensitive = p_case_sensitive self.case_sensitive = p_case_sensitive
...@@ -70,7 +71,7 @@ class GrepFilter(Filter): ...@@ -70,7 +71,7 @@ class GrepFilter(Filter):
# only be case sensitive when the expression contains at least one # only be case sensitive when the expression contains at least one
# capital character. # capital character.
self.case_sensitive = \ self.case_sensitive = \
len([c for c in p_expression if c.isupper()]) > 0 len([c for c in self.expression if c.isupper()]) > 0
def match(self, p_todo): def match(self, p_todo):
expr = self.expression expr = self.expression
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment