def test_case_sensitive(self): class MYFUNC(GenericFunction): type = DateTime assert isinstance(func.MYFUNC().type, DateTime) assert isinstance(func.MyFunc().type, DateTime) assert isinstance(func.mYfUnC().type, DateTime) assert isinstance(func.myfunc().type, DateTime)
def test_case_sensitive(self): reg = functions._registry["_default"] cs_reg = functions._case_sensitive_registry["_default"] class MYFUNC(GenericFunction): type = DateTime assert isinstance(func.MYFUNC().type, DateTime) assert isinstance(func.MyFunc().type, DateTime) assert isinstance(func.mYfUnC().type, DateTime) assert isinstance(func.myfunc().type, DateTime) in_("myfunc", reg) not_in("MYFUNC", reg) not_in("MyFunc", reg) in_("myfunc", cs_reg) eq_(set(cs_reg["myfunc"].keys()), set(["MYFUNC"])) with testing.expect_deprecated( "GenericFunction 'MyFunc' is already registered with" " different letter case, so the previously registered function " "'MYFUNC' is switched into case-sensitive mode. " "GenericFunction objects will be fully case-insensitive in a " "future release.", regex=False, ): class MyFunc(GenericFunction): type = Integer assert isinstance(func.MYFUNC().type, DateTime) assert isinstance(func.MyFunc().type, Integer) with pytest.raises(AssertionError): assert isinstance(func.mYfUnC().type, Integer) with pytest.raises(AssertionError): assert isinstance(func.myfunc().type, Integer) eq_(reg["myfunc"], functions._CASE_SENSITIVE) not_in("MYFUNC", reg) not_in("MyFunc", reg) in_("myfunc", cs_reg) eq_(set(cs_reg["myfunc"].keys()), set(["MYFUNC", "MyFunc"]))
def test_custom_w_quoted_name(self): class myfunc(GenericFunction): name = quoted_name("NotMyFunc", quote=True) identifier = "myfunc" self.assert_compile(func.myfunc(), '"NotMyFunc"()')
def test_custom_w_custom_name(self): class myfunc(GenericFunction): name = "notmyfunc" assert isinstance(func.notmyfunc(), myfunc) assert not isinstance(func.myfunc(), myfunc)
def test_custom_legacy_type(self): # in case someone was using this system class myfunc(GenericFunction): __return_type__ = DateTime assert isinstance(func.myfunc().type, DateTime)
def test_custom_type(self): class myfunc(GenericFunction): type = DateTime assert isinstance(func.myfunc().type, DateTime) self.assert_compile(func.myfunc(), "myfunc()")
def test_custom_default_namespace(self): class myfunc(GenericFunction): pass assert isinstance(func.myfunc(), myfunc) self.assert_compile(func.myfunc(), "myfunc()")