예제 #1
0
    def test_base_parser_passes_for_valid_expressions(self):
        assert parse_expression('foo:bar') == ('foo', 'bar')
        assert parse_expression('foo:>=bar') == ('foo', '>=bar')
        assert parse_expression('foo:bar|moo|boo') == ('foo', 'bar|moo|boo')
        assert parse_expression('foo:bar..moo') == ('foo', 'bar..moo')
        assert parse_expression('foo:~bar') == ('foo', '~bar')

        # Handles spaces
        assert parse_expression(' foo: bar ') == ('foo', 'bar')
        assert parse_expression('foo :>=bar ') == ('foo', '>=bar')
        assert parse_expression(' foo :bar|moo|boo') == ('foo', 'bar|moo|boo')
        assert parse_expression(' foo : bar..moo ') == ('foo', 'bar..moo')
        assert parse_expression(' foo : ~bar ') == ('foo', '~bar')
예제 #2
0
    def test_base_parser_raises_for_invalid_expressions(self):
        with self.assertRaises(QueryParserException):
            parse_expression('foo:bar:moo')

        with self.assertRaises(QueryParserException):
            parse_expression('foo')

        with self.assertRaises(QueryParserException):
            parse_expression(None)

        with self.assertRaises(QueryParserException):
            parse_expression(12)

        with self.assertRaises(QueryParserException):
            parse_expression('fff:')

        with self.assertRaises(QueryParserException):
            parse_expression(':dsf')

        with self.assertRaises(QueryParserException):
            parse_expression(':')