Beispiel #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"
         )
Beispiel #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")
Beispiel #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")
Beispiel #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"
Beispiel #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"
Beispiel #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"
Beispiel #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"
Beispiel #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"
Beispiel #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
Beispiel #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")
Beispiel #11
0
 def test_url_param_no_default(self) -> None:
     with app.test_request_context():
         cache = ExtraCache()
         self.assertEqual(cache.url_param("foo"), None)
Beispiel #12
0
def test_url_param_default() -> None:
    with app.test_request_context():
        cache = ExtraCache()
        assert cache.url_param("foo", "bar") == "bar"