Пример #1
0
    def test_fragment_construction(self):

        fragments = filtering.query_parser("alpha", [], [])
        assert len(fragments) == 1
        assert not fragments[0].negated
        assert fragments[0].fragment_type == filtering.TYPES.SEARCH_TERM

        fragments = filtering.query_parser("-alpha", [], [])
        assert len(fragments) == 1
        assert fragments[0].negated
        assert fragments[0].fragment_type == filtering.TYPES.SEARCH_TERM

        fragments = filtering.query_parser(':description="Another event"', ["description"], [])
        assert len(fragments) == 1, fragments
        assert fragments[0].fragment_type == filtering.TYPES.CONDITION
Пример #2
0
    def test_parser_splitting(self):

        fragments = filtering.query_parser("alpha beta", [], [])
        assert len(fragments) == 2

        fragments = filtering.query_parser('alpha "beta beta"', [], [])
        assert len(fragments) == 2

        fragments = filtering.query_parser("alpha", [], [])
        assert len(fragments) == 1

        fragments = filtering.query_parser("", [], [])
        assert len(fragments) == 0

        fragments = filtering.query_parser(':description="Another event"', ["description"], [])
        assert len(fragments) == 1

        with self.assertRaises(filtering.FilterException):
            filtering.query_parser(':description="Another event"', [], [])