Resolve #383: Test ld_context#403
Conversation
76a65e2 to
d1f4468
Compare
led02
left a comment
There was a problem hiding this comment.
Very good try, almost got it right... so no further docs needed? 😈
Clarified some decisions in the review.
|
Hmmm... tests don't work. Okay, I understand that the tests represent the should be API. |
led02
left a comment
There was a problem hiding this comment.
While running tests, I stumbled up some more mis-conceptions.
|
|
||
| def test_codemeta_prefix(ctx): | ||
| """Default vocabulary in context has the correct base IRI.""" | ||
| assert ctx.prefix[None] == "https://codemeta.github.io/terms/" |
There was a problem hiding this comment.
The CodeMeta 2.0 context introduces an codemeta prefix that points to that URI.
However, the default context is still the CodeMeta DOI.
| item = ctx["maintainer"] | ||
| assert item == "https://codemeta.github.io/terms/maintainer" |
There was a problem hiding this comment.
Okay, this test is actually correct but fails.
However, this is not quite unintended...
What you expect the context to do here is to fully expand the IRI (by applying a two-step resolution).
For this purpose, the implementation uses the PyLdProcessor which does a great job.
The ContextPrefix class is meant as a small util that does not implement the full JSON-LD algorithm.
- Remove duplicate tests of __get_item__ on tuples - This includes test parameters that we decided not to test, as the API doesn't see them as valid (list inputs), although they're supported at runtime. - Related: #403 (comment)
…ailures Extend #403: Mark xfailing tests, raise errors
ld_context#383This PR includes tests for
src/hermes/model/types/ld_context.py.It also includes some
FIXMEs to resolve during refactoring (#352).Finally, it adds missing licenses.
Note: I make some assumptions in the tests. Please check carefully if you agree.
__get_item__should only accept valid input, and raise an exception on invalid input. This is currently testing against Python'sTypeErrorandValueErrorwhich I think is the correct way of handling this.