Skip to content

Commit

Permalink
Merge pull request #91 from ralphbean/feature/is-to-equals
Browse files Browse the repository at this point in the history
Replace attr.is:value queries with attr == "value".
  • Loading branch information
ralphbean committed Feb 17, 2015
2 parents dd458f0 + 417928c commit 55afe8d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
22 changes: 22 additions & 0 deletions taskw/test/test_datas.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,25 @@ def test_add_and_retrieve_uda_string_url(self):
eq_(len(results), 1)
task = results[0]
eq_(task['someurl'], arbitrary_url)

def test_add_and_retrieve_uda_string_url_in_parens(self):
arbitrary_url = "http://www.someurl.com/1084/"

self.tw.config_overrides['uda'] = {
'someurl': {
'label': 'Some URL',
'type': 'string'
}
}
self.tw.task_add(
"foobar",
someurl=arbitrary_url,
)
results = self.tw.filter_tasks({
'and': [
('someurl.is', arbitrary_url),
],
})
eq_(len(results), 1)
task = results[0]
eq_(task['someurl'], arbitrary_url)
20 changes: 15 additions & 5 deletions taskw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import pytz
import six

from distutils.version import LooseVersion


DATE_FORMAT = '%Y%m%dT%H%M%SZ'

Expand Down Expand Up @@ -97,12 +99,20 @@ def encode_query(value, version, query=True):
])
)
else:
args.append(
'%s:%s' % (
k,
encode_task_value(k, v, query=query)
if k.endswith(".is") and version >= LooseVersion('2.4'):
args.append(
'%s == "%s"' % (
k[:-3],
encode_task_value(k, v, query=query)
)
)
else:
args.append(
'%s:%s' % (
k,
encode_task_value(k, v, query=query)
)
)
)

return args

Expand Down

0 comments on commit 55afe8d

Please sign in to comment.