Beispiel #1
0
def test_sub(pattern: str, repl: Union[str, callable], string: str,
             strict: bool, case_sensitive: bool, expected: str) -> None:
    Regex = regex.Regex()
    assert Regex.sub(pattern,
                     repl,
                     string,
                     strict=strict,
                     case_sensitive=case_sensitive) == expected
Beispiel #2
0
def test_search(pattern: str, string: str, strict: bool, case_sensitive: bool,
                expected: str) -> None:
    Regex = regex.Regex()
    output = Regex.search(pattern,
                          string,
                          strict=strict,
                          case_sensitive=case_sensitive)
    if output:
        assert output.group(0) == expected
    else:
        assert output == expected
import sqlparse
import re
import json
from termcolor import colored
import os
import logging
from pathlib import Path
from typing import List, Dict, Tuple
from sqlparse.sql import IdentifierList, Identifier, Comparison, Where, Parenthesis, TokenList, Function, Case, Operation, SquareBrackets, TypedLiteral
from sqlparse.tokens import Keyword, DML, CTE, Whitespace, Newline, Punctuation, Number, Literal, Comment, Name, Operator, Wildcard, Token, Error
from sql_translate import utils
from sql_translate.engine import regex, special_functions_handling

# case insensitive wrapper enforcing that re methods actually have an impact
Regex = regex.Regex()
SpecialFunctionHandlerHiveToPresto = special_functions_handling.SpecialFunctionHandlerHiveToPresto(
)


class _RecursiveTranslator():
    def __init__(self):
        pass


class RecursiveHiveToPresto(_RecursiveTranslator):
    def __init__(self):
        self.from_language = "Hive"
        self.to_language = "Presto"
        self.allowable_sqlparse_ttypes = {
            "varchar": [Literal.String.Single, Literal.String.Symbol],
            "bigint": [Number.Integer],
Beispiel #4
0
def test_sub_Exception() -> None:
    Regex = regex.Regex()
    with pytest.raises(Exception):
        Regex.sub(r"a", "you", "Hello world!")
Beispiel #5
0
def test_search_Exception() -> None:
    Regex = regex.Regex()
    with pytest.raises(Exception):
        Regex.search(r"a", "Hello world!")