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" )
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")
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")
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"
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"
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"
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"
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"
def test_url_param_no_default(app_context: AppContext) -> None: with app.test_request_context(): cache = ExtraCache() assert cache.url_param("foo") is None
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")
def test_url_param_no_default(self) -> None: with app.test_request_context(): cache = ExtraCache() self.assertEqual(cache.url_param("foo"), None)
def test_url_param_default() -> None: with app.test_request_context(): cache = ExtraCache() assert cache.url_param("foo", "bar") == "bar"