def test_filter_years_valid_out_of_range(self): mixin = LearningSiteSearchMixin() mixin.request = RequestFactory().get( '/', {'q': 'Alpha', 'start': '1900', 'end': '1920'}) mixin.request.user = AnonymousUser() qs = mixin.filter(LearningSite.objects.all()) self.assertEquals(qs.count(), 0)
def test_filter(self): mixin = LearningSiteSearchMixin() mixin.request = RequestFactory().get('/', {'q': 'Alpha'}) mixin.request.user = AnonymousUser() qs = mixin.filter(LearningSite.objects.all()) self.assertEquals(qs.count(), 1) self.assertEquals(qs.first(), self.site1)
def test_filter_null_characters_end_year(self): mixin = LearningSiteSearchMixin() mixin.request = RequestFactory().get( '/', {'q': '', 'start': '1900', 'end': '\x00'}) mixin.request.user = AnonymousUser() qs = mixin.filter(LearningSite.objects.all()) self.assertEquals(qs.count(), 3)
def test_filter_years_invalid(self): mixin = LearningSiteSearchMixin() mixin.request = RequestFactory().get( '/', {'q': '', 'start': 'abcde', 'end': '4567'}) mixin.request.user = AnonymousUser() qs = mixin.filter(LearningSite.objects.all()) self.assertEquals(qs.count(), 3)
def test_filter_empty(self): mixin = LearningSiteSearchMixin() mixin.request = RequestFactory().get('/', {}) mixin.request.user = AnonymousUser() qs = mixin.filter(LearningSite.objects.all()) self.assertEquals(qs.count(), 3)