Skip to content

Commit

Permalink
Fix details deserialization error
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvbrdn committed Aug 10, 2024
1 parent e4f1384 commit fb669dc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "regexsolver"
version = "1.0.1"
version = "1.0.2"
authors = [
{ name = "RegexSolver", email = "[email protected]" }
]
Expand Down
2 changes: 1 addition & 1 deletion regexsolver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
self.base_url = "https://api.regexsolver.com/"
self.api_token = None
self.headers = {
'User-Agent': 'RegexSolver Python / 1.0.1',
'User-Agent': 'RegexSolver Python / 1.0.2',
'Content-Type': 'application/json'
}

Expand Down
2 changes: 1 addition & 1 deletion regexsolver/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Cardinality(BaseModel):
Class that represent the number of possible values.
"""
type: str
value: Optional[int]
value: Optional[int] = None

def is_infinite(self) -> bool:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="regexsolver",
version="1.0.1",
version="1.0.2",
description="RegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.",
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
Expand Down
12 changes: 12 additions & 0 deletions tests/assets/response_getDetails_infinite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "details",
"cardinality": {
"type": "Infinite"
},
"length": [
2,
null
],
"empty": false,
"total": false
}
17 changes: 17 additions & 0 deletions tests/term_operation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ def test_get_details(self):
str(details)
)

def test_get_details_infinite(self):
with open('tests/assets/response_getDetails_infinite.json') as response:
json_response = json.load(response)
with requests_mock.Mocker() as mock:
mock.post(
"https://api.regexsolver.com/api/analyze/details",
json=json_response, status_code=200
)

term = Term.regex(r"de.*")
details = term.get_details()

self.assertEqual(
"Details[cardinality=Infinite, length=Length[minimum=2, maximum=None], empty=False, total=False]",
str(details)
)

def test_generate_strings(self):
with open('tests/assets/response_generateStrings.json') as response:
json_response = json.load(response)
Expand Down

0 comments on commit fb669dc

Please sign in to comment.