WIP: RDF prefix issue fix in rdflib dumper#184
Conversation
| self.assertIn((ORCID['4567'], personinfo.phone, Literal("555-555-5555")), g) | ||
|
|
||
| def test_prefixes(self): | ||
| with open(OUT, encoding='UTF-8') as file: |
There was a problem hiding this comment.
Note that this introduces dependencies between tests. It assumes the tests will be executed by the test framework in order, and that the developer who it iteratively testing will run things in order.
I would just move this into test_rdflib_dumper
| with open(OUT, encoding='UTF-8') as file: | ||
| for line in file: | ||
| if 'prefix' in line: | ||
| print(line) |
There was a problem hiding this comment.
we should avoid prints in tests, as this makes the test output very verbose and hard to debug
you can use logging.info
But more importantly, this test doesn't test for anything! Recall that this PR is to ensure certain behavior at the turtle syntactic level. I think you want to be testing:
- that orcid and sdo prefixes are in the prefix with the expected short form. E.g. check for strings
prefix: ORCIDandprefix: SDO - that CURIEs are used in the main body of the turtle. E.g. check for strings
sdo:PersonandORCID:1234
| SDO = Namespace('http://schema.org/') | ||
|
|
||
|
|
||
| class RdfLibDumperTestCase(unittest.TestCase): |
There was a problem hiding this comment.
it's good to name the class and tests to something specific to what is being tested (we need to update our guidelines on this)
|
|
||
| class RdfLibDumperTestCase(unittest.TestCase): | ||
|
|
||
| def test_rdflib_dumper(self): |
There was a problem hiding this comment.
this is a good test to have to ensure that rdflib_dumper is working as expected - but note this isn't actually testing the issue at hand, which is specifically about prefixes.
I think it's good to keep these tests, but just add a note that this is testing generic rdflib dumper functionality
Codecov Report
@@ Coverage Diff @@
## main #184 +/- ##
==========================================
+ Coverage 62.60% 63.06% +0.46%
==========================================
Files 49 50 +1
Lines 5447 5491 +44
Branches 1551 1558 +7
==========================================
+ Hits 3410 3463 +53
+ Misses 1651 1605 -46
- Partials 386 423 +37
Continue to review full report at Codecov.
|
| personinfo = Namespace('https://w3id.org/linkml/examples/personinfo/') | ||
| SDO = Namespace('http://schema.org/') | ||
|
|
||
| def __init__(self, *args, **kwargs): |
There was a problem hiding this comment.
you might want to consider setUp() here, see https://docs.python.org/3/library/unittest.html#organizing-test-code
Fixes linkml/linkml#429