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