Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ghandic committed Dec 3, 2023
1 parent dac794c commit 8a81e57
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions jsf/tests/test_default_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ def test_fake_object_pattern_properties(TestData):
assert len(all_int_names) > 0


def assert_regex(pattern: str, string: str, info:Optional[str]) -> None:
assert(bool(re.match(pattern, string))), (string, info)
def assert_regex(pattern: str, string: str, info: Optional[str]) -> None:
assert bool(re.match(pattern, string)), (string, info)


def test_fake_string_format(TestData):
Expand All @@ -326,13 +326,21 @@ def test_fake_string_format(TestData):

assert isinstance(p.generate(), dict)
fake_data = [p.generate() for _ in range(10)]

for d in fake_data:
assert_regex(r".*@.*", d["email"], "email")
assert_regex(r".*@.*", d["idn-email"], "idn-email")
assert_regex(r"\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.*\d*[-\+]\d{2}\:\d{2}", d["date-time"], "date-time")
assert_regex(
r"\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.*\d*[-\+]\d{2}\:\d{2}",
d["date-time"],
"date-time",
)
assert_regex(r"\d{4}-\d{2}-\d{2}", d["date"], "date")
assert_regex(r"^(-?)P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$", d["duration"], "duration")
assert_regex(
r"^(-?)P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$",
d["duration"],
"duration",
)
assert_regex(r"\d{2}\:\d{2}\:\d{2}\.*\d*[-\+]\d{2}\:\d{2}", d["time"], "time")
assert_regex(r"[a-zA-Z0-9+-\.]{1,33}\.[a-z]{2,4}", d["hostname"], "hostname")
assert_regex(r"[a-zA-Z0-9+-\.]{1,33}\.[a-z]{2,4}", d["idn-hostname"], "idn-hostname")
Expand Down

0 comments on commit 8a81e57

Please sign in to comment.