From 1e004a8ad9871199ca3ec7d1f6fe76f6493e98c4 Mon Sep 17 00:00:00 2001 From: Chris Brew Date: Mon, 19 Feb 2024 10:24:08 -0500 Subject: [PATCH 1/2] test and fix for issue #167 --- eyecite/utils.py | 2 +- tests/test_ResolveTest.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eyecite/utils.py b/eyecite/utils.py index b642d23..509bc72 100644 --- a/eyecite/utils.py +++ b/eyecite/utils.py @@ -122,7 +122,7 @@ def hash_sha256(dictionary: dict) -> int: """ # Convert the dictionary to a JSON string - json_str: str = json.dumps(dictionary, sort_keys=True) + json_str: str = json.dumps(dictionary, sort_keys=True,default=str) # Convert the JSON string to bytes json_bytes: bytes = json_str.encode("utf-8") diff --git a/tests/test_ResolveTest.py b/tests/test_ResolveTest.py index 8461ba7..bff0d3c 100644 --- a/tests/test_ResolveTest.py +++ b/tests/test_ResolveTest.py @@ -104,6 +104,9 @@ def checkResolution( self.assertResolution(citations, expected_resolution_dict) + def test_issue_167(self): + self.checkResolution((0,'25 Texas L.Rev. 199')) + def test_full_resolution(self): # Test resolving a single, full citation self.checkResolution( From e1b11026f6f00674a9e239d4f549842df10703d0 Mon Sep 17 00:00:00 2001 From: Chris Brew Date: Sat, 24 Feb 2024 14:49:13 -0500 Subject: [PATCH 2/2] refactor(utils): Update style of the hash_sha256 method --- eyecite/utils.py | 3 ++- tests/test_ResolveTest.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/eyecite/utils.py b/eyecite/utils.py index 509bc72..b2bb66a 100644 --- a/eyecite/utils.py +++ b/eyecite/utils.py @@ -122,7 +122,8 @@ def hash_sha256(dictionary: dict) -> int: """ # Convert the dictionary to a JSON string - json_str: str = json.dumps(dictionary, sort_keys=True,default=str) + # default needed because of dates + json_str: str = json.dumps(dictionary, sort_keys=True, default=str) # Convert the JSON string to bytes json_bytes: bytes = json_str.encode("utf-8") diff --git a/tests/test_ResolveTest.py b/tests/test_ResolveTest.py index bff0d3c..61c4898 100644 --- a/tests/test_ResolveTest.py +++ b/tests/test_ResolveTest.py @@ -105,8 +105,8 @@ def checkResolution( self.assertResolution(citations, expected_resolution_dict) def test_issue_167(self): - self.checkResolution((0,'25 Texas L.Rev. 199')) - + self.checkResolution((0, "25 Texas L.Rev. 199")) + def test_full_resolution(self): # Test resolving a single, full citation self.checkResolution(