Esempio n. 1
0
def test_phone_util_override(app):
    class MyPhoneUtil:
        def __init__(self, app):
            pass

        def validate_phone_number(self, input_data):
            return "call-me"

        def get_canonical_form(self, input_data):
            return "very-canonical"

    app.security = Security()
    app.security.init_app(app, phone_util_cls=MyPhoneUtil)

    with app.app_context():
        assert uia_phone_mapper("55") == "very-canonical"
def test_phone_util_override(app):
    class MyPhoneUtil(object):
        def validate_phone_number(self, input_data):
            return "call-me"

        def get_canonical_form(self, input_data):
            return "very-canonical"

    app.security = Security()
    app.security.init_app(app, phone_util_cls=MyPhoneUtil)

    with app.app_context():
        client = app.test_client()
        # trigger @before first request
        client.get("/login")
        assert uia_phone_mapper("55") == "very-canonical"