Esempio n. 1
0
 def test_url_param_unescaped_default_form_data(self) -> None:
     with app.test_request_context(
         query_string={"form_data": json.dumps({"url_params": {"foo": "O'Brien"}})}
     ):
         cache = ExtraCache(dialect=dialect())
         self.assertEqual(
             cache.url_param("bar", "O'Malley", escape_result=False), "O'Malley"
         )
Esempio n. 2
0
 def test_url_param_escaped_form_data(self) -> None:
     with app.test_request_context(
             query_string={
                 "form_data": json.dumps({"url_params": {
                     "foo": "O'Brien"
                 }})
             }):
         cache = ExtraCache(dialect=dialect())
         self.assertEqual(cache.url_param("foo"), "O''Brien")
Esempio n. 3
0
 def test_url_param_form_data(self) -> None:
     with app.test_request_context(
             query_string={
                 "form_data": json.dumps({"url_params": {
                     "foo": "bar"
                 }})
             }):
         cache = ExtraCache()
         self.assertEqual(cache.url_param("foo"), "bar")
Esempio n. 4
0
def test_url_param_unescaped_form_data() -> None:
    with app.test_request_context(
            query_string={
                "form_data": json.dumps({"url_params": {
                    "foo": "O'Brien"
                }})
            }):
        cache = ExtraCache(dialect=dialect())
        assert cache.url_param("foo", escape_result=False) == "O'Brien"
Esempio n. 5
0
def test_url_param_escaped_default_form_data() -> None:
    with app.test_request_context(
            query_string={
                "form_data": json.dumps({"url_params": {
                    "foo": "O'Brien"
                }})
            }):
        cache = ExtraCache(dialect=dialect())
        assert cache.url_param("bar", "O'Malley") == "O''Malley"
Esempio n. 6
0
def test_url_param_escaped_form_data(app_context: AppContext) -> None:
    with app.test_request_context(
        query_string={"form_data": json.dumps({"url_params": {"foo": "O'Brien"}})}
    ):
        cache = ExtraCache(dialect=dialect())
        assert cache.url_param("foo") == "O''Brien"
Esempio n. 7
0
def test_url_param_form_data(app_context: AppContext) -> None:
    with app.test_request_context(
        query_string={"form_data": json.dumps({"url_params": {"foo": "bar"}})}
    ):
        cache = ExtraCache()
        assert cache.url_param("foo") == "bar"
Esempio n. 8
0
def test_url_param_query(app_context: AppContext) -> None:
    with app.test_request_context(query_string={"foo": "bar"}):
        cache = ExtraCache()
        assert cache.url_param("foo") == "bar"
Esempio n. 9
0
def test_url_param_no_default(app_context: AppContext) -> None:
    with app.test_request_context():
        cache = ExtraCache()
        assert cache.url_param("foo") is None
Esempio n. 10
0
 def test_url_param_query(self) -> None:
     with app.test_request_context(query_string={"foo": "bar"}):
         cache = ExtraCache()
         self.assertEqual(cache.url_param("foo"), "bar")
Esempio n. 11
0
 def test_url_param_no_default(self) -> None:
     with app.test_request_context():
         cache = ExtraCache()
         self.assertEqual(cache.url_param("foo"), None)
Esempio n. 12
0
def test_url_param_default() -> None:
    with app.test_request_context():
        cache = ExtraCache()
        assert cache.url_param("foo", "bar") == "bar"