示例#1
0
    def test_it_should_sanitize_search_terms(self):
        """Removes street terms from search terms"""
        filter = query(index('address'), search('Plaza Santa Ana'))

        result = self.filter(filter, (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(result, contains(
            has_property('idestacion', AVAILABLE_STATION['idestacion'])))
示例#2
0
    def test_it_should_search_by_field(self):
        """Searches by given field"""
        filter = query(index('address'), search('Plaza Santa Ana'))

        result = self.filter(filter, (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(result, contains(
            has_property('idestacion', AVAILABLE_STATION['idestacion'])))
示例#3
0
    def test_it_should_sanitize_search_terms(self):
        """Removes street terms from search terms"""
        filter = query(index('address'), search('Plaza Santa Ana'))

        result = self.filter(filter, (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(
            result,
            contains(
                has_property('idestacion', AVAILABLE_STATION['idestacion'])))
示例#4
0
    def test_it_should_search_by_field(self):
        """Searches by given field"""
        filter = query(index('address'), search('Plaza Santa Ana'))

        result = self.filter(filter, (AVAILABLE_STATION, NO_BIKES_STATION))

        assert_that(
            result,
            contains(
                has_property('idestacion', AVAILABLE_STATION['idestacion'])))
示例#5
0
    def test_it_should_compose_several_filters_in_order(self):
        """Should apply all filters in order and keep the result"""
        def marker(n):
            def filter(stations):
                for station in stations:
                    setattr(station, 'mark', n)
                    setattr(station, 'marked_by_{}'.format(n), True)
                    yield station
            return filter

        result = self.filter(query(marker(1), marker(2)),
                             (AVAILABLE_STATION, FIRST_STATION))

        assert_that(result, only_contains(all_of(
            has_property('mark', 2),
            has_property('marked_by_1', True),
            has_property('marked_by_2', True),
        )))
示例#6
0
    def test_it_should_compose_several_filters_in_order(self):
        """Should apply all filters in order and keep the result"""
        def marker(n):
            def filter(stations):
                for station in stations:
                    setattr(station, 'mark', n)
                    setattr(station, 'marked_by_{}'.format(n), True)
                    yield station

            return filter

        result = self.filter(query(marker(1), marker(2)),
                             (AVAILABLE_STATION, FIRST_STATION))

        assert_that(
            result,
            only_contains(
                all_of(
                    has_property('mark', 2),
                    has_property('marked_by_1', True),
                    has_property('marked_by_2', True),
                )))