def test_history_num_args(mock_persist_driver): mock_persist_driver.enable_history_support() with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'HISTORY(@some_id, 1)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'HISTORY(@some_id, 1, 2, 3)', 0)
def test_history_arg_type(mock_persist_driver): mock_persist_driver.enable_history_support() with pytest.raises(InvalidArgumentKind) as exc_info: Function.parse(None, 'HISTORY(1, 2, 3)', 0) assert exc_info.value.name == 'HISTORY' assert exc_info.value.num == 1 assert exc_info.value.pos == 9
def test_lutli_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'LUTLI(1)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'LUTLI(1, 2)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'LUTLI(1, 2, 3, 4)', 0)
def test_ceil_parse(): e = Function.parse(None, 'CEIL(1)', 0) assert isinstance(e, rounding.CeilFunction)
def test_floor_parse(): e = Function.parse(None, 'FLOOR(1)', 0) assert isinstance(e, rounding.FloorFunction)
def test_round_parse(): e = Function.parse(None, 'ROUND(1)', 0) assert isinstance(e, rounding.RoundFunction)
def test_shl_parse(): e = Function.parse(None, 'SHL(1, 2)', 0) assert isinstance(e, bitwise.SHLFunction)
def test_bitxor_parse(): e = Function.parse(None, 'BITXOR(1, 2)', 0) assert isinstance(e, bitwise.BitXOrFunction)
def test_bitnot_parse(): e = Function.parse(None, 'BITNOT(1)', 0) assert isinstance(e, bitwise.BitNotFunction)
def test_bom_parse(): e = Function.parse(None, 'BOM()', 0) assert isinstance(e, date.BOMFunction)
def test_year_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'YEAR(1, 2)', 0)
def test_date_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'DATE(2019, 3, 14, 1, 2)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'DATE(2019, 3, 14, 1, 2, 3, 4)', 0)
def test_date_parse(): e = Function.parse(None, 'DATE(2019, 3, 14, 1, 2, 3)', 0) assert isinstance(e, date.DateFunction)
def test_year_parse(): e = Function.parse(None, 'YEAR()', 0) assert isinstance(e, date.YearFunction)
def test_millisecond_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'MILLISECOND(1)', 0)
def test_dow_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'DOW(1, 2)', 0)
def test_bitand_parse(): e = Function.parse(None, 'BITAND(1, 2)', 0) assert isinstance(e, bitwise.BitAndFunction)
def test_month_parse(): e = Function.parse(None, 'MONTH()', 0) assert isinstance(e, date.MonthFunction)
def test_bitnot_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'BITNOT()', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'BITNOT(1, 2)', 0)
def test_month_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'MONTH(1, 2)', 0)
def test_bitxor_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'BITXOR(1)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'BITXOR(1, 2, 3)', 0)
def test_hmsinterval_parse(): e = Function.parse(None, 'HMSINTERVAL(1, 1, 1, 2, 2, 2)', 0) assert isinstance(e, date.HMSIntervalFunction)
def test_shl_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'SHL(1)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'SHL(1, 2, 3)', 0)
def test_day_parse(): e = Function.parse(None, 'DAY()', 0) assert isinstance(e, date.DayFunction)
def test_round_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'ROUND()', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'ROUND(1, 2, 3)', 0)
def test_mdinterval_parse(): e = Function.parse(None, 'MDINTERVAL(1, 1, 2, 2)', 0) assert isinstance(e, date.MDIntervalFunction)
def test_floor_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'FLOOR()', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'FLOOR(1, 2)', 0)
def test_mdinterval_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'MDINTERVAL(1, 2, 3)', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'MDINTERVAL(1, 2, 3, 4, 5)', 0)
def test_ceil_num_args(): with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'CEIL()', 0) with pytest.raises(InvalidNumberOfArguments): Function.parse(None, 'CEIL(1, 2)', 0)
def test_dow_parse(): e = Function.parse(None, 'DOW()', 0) assert isinstance(e, date.DOWFunction)