diff --git a/orlo/queries.py b/orlo/queries.py index 30d4261..aefc517 100644 --- a/orlo/queries.py +++ b/orlo/queries.py @@ -183,13 +183,17 @@ def releases(**kwargs): if any(field.startswith('package_') for field in kwargs.keys()) \ or "status" in kwargs.keys(): # Package attributes need the join, as does status as it's really a - # package - # attribute + # package attribute query = db.session.query(Release).join(Package) else: # No need to join on package if none of our params need it query = db.session.query(Release) + for key in kwargs.keys(): + if isinstance(kwargs[key], bool): + continue + if kwargs[key].lower() in ['null', 'none']: + kwargs[key] = None try: query = apply_filters(query, kwargs) except AttributeError as e: diff --git a/tests/test_contract.py b/tests/test_contract.py index 1950b94..a4bb4ba 100644 --- a/tests/test_contract.py +++ b/tests/test_contract.py @@ -487,8 +487,12 @@ def _get_releases_time_filter(self, field, finished=False): yesterday = (now - timedelta(days=1)).strftime(t_format) tomorrow = (now + timedelta(days=1)).strftime(t_format) - r_yesterday = self._get_releases(filters=['{}={}'.format(field, yesterday)]) - r_tomorrow = self._get_releases(filters=['{}={}'.format(field, tomorrow)]) + r_yesterday = self._get_releases( + filters=['{}={}'.format(field, yesterday)] + ) + r_tomorrow = self._get_releases( + filters=['{}={}'.format(field, tomorrow)] + ) return r_yesterday, r_tomorrow @@ -501,6 +505,15 @@ def test_get_release_filter_stime_before(self): self.assertEqual(3, len(r_tomorrow['releases'])) self.assertEqual(0, len(r_yesterday['releases'])) + def test_get_release_filter_ftime_null(self): + """ + Filter on releases that don't have a finish time + """ + releases = self._get_releases( + filters=['{}={}'.format('ftime', 'null')] + ) + self.assertEqual(len(releases['releases']), 0) + def test_get_release_filter_stime_after(self): """ Filter on releases that started after a particular time