Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Oct 13, 2023
1 parent bda2c64 commit 7c208cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/curies/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,16 +866,18 @@ def format_curie(self, prefix: str, identifier: str) -> str:
return f"{prefix}{self.delimiter}{identifier}"

@overload
def compress(self, uri: str, *, strict: Literal[True], passthrough: bool) -> str:
def compress(self, uri: str, *, strict: Literal[True] = True, passthrough: bool = False) -> str:
...

@overload
def compress(self, uri: str, *, strict: Literal[False], passthrough: Literal[True]) -> str:
def compress(
self, uri: str, *, strict: Literal[False] = False, passthrough: Literal[True] = True
) -> str:
...

@overload
def compress(
self, uri: str, *, strict: Literal[False], passthrough: Literal[False]
self, uri: str, *, strict: Literal[False] = False, passthrough: Literal[False] = False
) -> Optional[str]:
...

Expand Down
8 changes: 6 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,17 @@ def _assert_convert(self, converter: Converter):
("OBO:unnamespaced", "http://purl.obolibrary.org/obo/unnamespaced"),
]:
self.assertEqual(curie, converter.compress(uri))
self.assertEqual(curie, converter.compress_strict(uri))
self.assertEqual(curie, converter.compress(uri, strict=True))
self.assertEqual(uri, converter.expand(curie))
self.assertEqual(uri, converter.expand_strict(curie))

self.assertIsNone(converter.compress("http://example.org/missing:00000"))
self.assertEqual(
"http://example.org/missing:00000",
converter.compress("http://example.org/missing:00000", passthrough=True),
)
with self.assertRaises(CompressionError):
converter.compress_strict("http://example.org/missing:00000")
converter.compress("http://example.org/missing:00000", strict=True)

self.assertIsNone(converter.expand("missing:00000"))
with self.assertRaises(ExpansionError):
Expand Down

0 comments on commit 7c208cb

Please sign in to comment.