Skip to content

Commit bb0aaa2

Browse files
authored
Merge pull request #93 from stphivos/carta-exclude-none-row-from-filter-comparison
Exclude none row from filter comparison
2 parents b902ff5 + e9abdc3 commit bb0aaa2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ matrix:
3636
- TOX_ENV=py36-dj21-drf37
3737

3838
install:
39-
- travis_retry pip install "virtualenv<14.0.0" "tox>=1.9" "coverage<4"
39+
- travis_retry pip install "virtualenv<14.0.0" "tox>=1.9" "coverage<4" "setuptools<40.0.0"
4040

4141
script:
4242
- tox -e $TOX_ENV

django_mock_queries/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ def is_match(first, second, comparison=None):
140140
COMPARISON_IEXACT: lambda: first.lower() == second.lower(),
141141
COMPARISON_CONTAINS: lambda: second in first,
142142
COMPARISON_ICONTAINS: lambda: second.lower() in first.lower(),
143-
COMPARISON_GT: lambda: first > second,
144-
COMPARISON_GTE: lambda: first >= second,
145-
COMPARISON_LT: lambda: first < second,
146-
COMPARISON_LTE: lambda: first <= second,
147-
COMPARISON_IN: lambda: first in second,
143+
COMPARISON_GT: lambda: first > second if first else False,
144+
COMPARISON_GTE: lambda: first >= second if first else False,
145+
COMPARISON_LT: lambda: first < second if first else False,
146+
COMPARISON_LTE: lambda: first <= second if first else False,
147+
COMPARISON_IN: lambda: first in second if first else False,
148148
COMPARISON_STARTSWITH: lambda: first.startswith(second),
149149
COMPARISON_ISTARTSWITH: lambda: first.lower().startswith(second.lower()),
150150
COMPARISON_ENDSWITH: lambda: first.endswith(second),

tests/test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def test_is_match_greater_than_value_check(self):
158158
result = utils.is_match(3, 5, constants.COMPARISON_GT)
159159
assert result is False
160160

161+
result = utils.is_match(None, 5, constants.COMPARISON_GT)
162+
assert result is False
163+
161164
def test_is_match_greater_than_equal_to_value_check(self):
162165
result = utils.is_match(5, 3, constants.COMPARISON_GTE)
163166
assert result is True
@@ -168,13 +171,19 @@ def test_is_match_greater_than_equal_to_value_check(self):
168171
result = utils.is_match(3, 5, constants.COMPARISON_GTE)
169172
assert result is False
170173

174+
result = utils.is_match(None, 5, constants.COMPARISON_GTE)
175+
assert result is False
176+
171177
def test_is_match_less_than_value_check(self):
172178
result = utils.is_match(1, 2, constants.COMPARISON_LT)
173179
assert result is True
174180

175181
result = utils.is_match(2, 2, constants.COMPARISON_LT)
176182
assert result is False
177183

184+
result = utils.is_match(None, 5, constants.COMPARISON_LT)
185+
assert result is False
186+
178187
def test_is_match_less_than_equal_to_value_check(self):
179188
result = utils.is_match(1, 2, constants.COMPARISON_LTE)
180189
assert result is True
@@ -185,6 +194,9 @@ def test_is_match_less_than_equal_to_value_check(self):
185194
result = utils.is_match(2, 1, constants.COMPARISON_LTE)
186195
assert result is False
187196

197+
result = utils.is_match(None, 5, constants.COMPARISON_LTE)
198+
assert result is False
199+
188200
def test_is_match_isnull_check(self):
189201
result = utils.is_match(1, True, constants.COMPARISON_ISNULL)
190202
assert result is False

0 commit comments

Comments
 (0)