Skip to content

Commit

Permalink
fix(web) issue2551382 - case 1# or 1& failing.
Browse files Browse the repository at this point in the history
HAndle case for integer followed by a url delimiter. e.g. 1# and 1&
  • Loading branch information
rouilj committed Dec 15, 2024
1 parent 0e10c25 commit 9dfb1e5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/test_liveserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# ruff: noqa: E402
from hypothesis import example, given, settings
from hypothesis.strategies import binary, characters, none, one_of, sampled_from, text
from hypothesis.strategies import binary, characters, emails, none, one_of, sampled_from, text

except ImportError:
from .pytest_patcher import mark_class
Expand All @@ -48,7 +48,7 @@ def noop_strategy(*args, **kwargs):
# define the decorator functions
example = given = settings = noop_decorators_with_args
# and stratgies using in decorators
binary = characters = none = one_of = sampled_from = text = noop_strategy
binary = characters = emails, none = one_of = sampled_from = text = noop_strategy


try:
Expand Down Expand Up @@ -213,6 +213,7 @@ class FuzzGetUrls(WsgiSetup, ClientSetup):

@given(sampled_from(['@verbose', '@page_size', '@page_index']),
one_of(characters(),text(min_size=1)))
@example("@verbose", "1#")
@settings(max_examples=_max_examples,
deadline=10000) # 10000ms
def test_class_url_param_accepting_integer_values(self, param, value):
Expand All @@ -224,17 +225,21 @@ def test_class_url_param_accepting_integer_values(self, param, value):
query = '%s=%s' % (param, value)
f = session.get(url, params=query)
try:
# test case '0#'
if len(value) > 1 and value[-1] in ('#', '&'):
value = value[:-1]
if int(value) >= 0:
self.assertEqual(f.status_code, 200)
except ValueError:
if value in ['#', '&']:
if value in ('#', '&'):
self.assertEqual(f.status_code, 200)
else:
# invalid value for param
self.assertEqual(f.status_code, 400)

@given(sampled_from(['@verbose']),
one_of(characters(),text(min_size=1)))
@example("@verbose", "1#")
@settings(max_examples=_max_examples,
deadline=10000) # 10000ms
def test_element_url_param_accepting_integer_values(self, param, value):
Expand All @@ -246,6 +251,9 @@ def test_element_url_param_accepting_integer_values(self, param, value):
query = '%s=%s' % (param, value)
f = session.get(url, params=query)
try:
# test case '0#'
if len(value) > 1 and value[-1] in ('#', '&'):
value = value[:-1]
if int(value) >= 0:
self.assertEqual(f.status_code, 200)
except ValueError:
Expand All @@ -255,7 +263,6 @@ def test_element_url_param_accepting_integer_values(self, param, value):
# invalid value for param
self.assertEqual(f.status_code, 400)


@skip_requests
class BaseTestCases(WsgiSetup, ClientSetup):
"""Class with all tests to run against wsgi server. Is reused when
Expand Down

0 comments on commit 9dfb1e5

Please sign in to comment.