Skip to content

Commit

Permalink
Merge pull request #44 from hsolbrig/rdflib_testing_fix
Browse files Browse the repository at this point in the history
Rdflib testing fix
  • Loading branch information
hsolbrig authored Jun 15, 2022
2 parents bb11666 + 845c70e commit 4086331
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 25 deletions.
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Chris Mungall <[email protected]>
GitHub Action <[email protected]>
Harold Solbrig <[email protected]>
clin113jhu <[email protected]>
cmungall <[email protected]>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
hsolbrig <[email protected]>
hsolbrig <[email protected]>
jiaola <[email protected]>
62 changes: 46 additions & 16 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
CHANGES
=======

* Minor tweak to make versioning compatible back to 3.7.9
* Automatically generated requirements and Pipfile.lock
* Try testing ANY push vs. just main
* Omit single quotes from prefix parse as well just to be sure
* Resolve issue #39

v0.1.11
-------

* Resolve issue #33
* Fix issue #33
* Automatically generated requirements and Pipfile.lock
* rdflibshim. fixes #30
* Testing issue #24. Issue appears to have been fixed

v0.1.10
-------

* Add skip option to tests
* Fix issue w/ empty ("") literals
* Fix issue where literals were being parsed as URI's
* Checking that issue #26 got fixed in the process. It did
* Automatically generated requirements and Pipfile.lock
* Fixed parsing error where parens had priority over quotes

v0.1.9
------

* Changed the Ontology.imports signature to allow an OntologyDocument. Changed Prefix to accept strings
* Enable SNOMED test by adding \_\_init\_\_.py to directory
* Fix (strangely) undetected typo dataproperty\_axioms

v0.1.8
------

* Finalize test
* Added emit\_functional\_definition to to\_rdf function

v0.1.7
------

* Switch to https for the owl converter
* Force python 3.8 and above and lock to rdflib 5.0
* Automatically generated requirements and Pipfile.lock
* Update README.md
* Bump urllib3 from 1.26.4 to 1.26.5
* Update dependency on urllib3

v0.1.6
Expand Down Expand Up @@ -47,27 +93,11 @@ v0.1.5
* Implemented to\_rdf for DisjointClasses, DataAllValuesFrom and DisjointDataProperties
* Added \_\_str\_\_ method to ontology document to simplify serialization
* Release version 0.1.4

v0.1.4
------

* Add version badges
* Don't emit a DataType declaration for literal data types
* Several fixes on literal representation

v0.1.3
------

* Update dependencies

v0.1.1
------

* More work on singleton property

v0.1.0
------

* Fix issue in SubObjectPropertyOf RDF emission
* Fix issues where BNode parsing stopped working
* Implemented to\_rdf for SubObjectPropertyOf, ObjectPropertyDomain, FunctionalObjectProperty and InverseFunctionalObjectProperty
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ verify_ssl = true
requests = "*"

[packages]
rdflib = ">=5.0.0, !=6.1.*"
rdflib = ">=5.0.0"
rdflib-shim = "*"
pyjsg = ">=0.11.6"
rfc3987 = "*"
Expand Down
8 changes: 4 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
bcp47
pyjsg>=0.11.6
rdflib-shim
rdflib>=5.0.0, !=6.1.*
rdflib>=5.0.0
rfc3987
6 changes: 6 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import rdflib

# Set log level for debugging tests here
import os
Expand All @@ -9,3 +10,8 @@

# Set this to False if you want to make sure some of the big inputs work
SKIP_LONG_TESTS = True

# rdflib 6.1.1 has a LONG list of pre-assigned prefixes. This breaks some of our tests and the rdflib
# community promises to fix it (some day...). For now, we won't run tests on this version
RDFLIB_PREFIXES_ARE_BROKEN = rdflib.__version__ == "6.1.1"
PREFIXES_BROKEN_MESSAGE = "rdflib 6.1.1 emits a LOT of prefixes. Test skipped!"
2 changes: 2 additions & 0 deletions tests/test_base/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from funowl.annotations import Annotation
from funowl.ontology_document import Ontology, OntologyDocument
from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE
from tests.utils.base import TestBase


Expand All @@ -21,6 +22,7 @@ def expected(defs: List[str]) -> str:


class OwlBasicsTestCase(TestBase):
@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_ontology_document(self):
doc = OntologyDocument()
self.assertEqual(expected([]), str(doc.to_functional().getvalue()))
Expand Down
3 changes: 3 additions & 0 deletions tests/test_base/test_ontologydocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from funowl import Prefix
from funowl.ontology_document import Ontology, Import, OntologyDocument
from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE
from tests.utils.base import TestBase, A


Expand All @@ -20,6 +21,7 @@ def test_import_to_rdf(self):

class OntologyDocumentTestCase(TestBase):

@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_ontology_document_prefixes(self):
doc = OntologyDocument(A, ex=EX)
self.assertEqual("""Prefix( xml: = <http://www.w3.org/XML/1998/namespace> )
Expand All @@ -32,6 +34,7 @@ def test_ontology_document_prefixes(self):
Ontology( )""", doc.to_functional().getvalue())

@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_use_case_one(self):
from rdflib import RDFS, OWL
od = OntologyDocument(ontology=Ontology(iri="http://www.example.com/ontology1"))
Expand Down
3 changes: 3 additions & 0 deletions tests/test_base/test_prefixdeclarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from rdflib import RDF, URIRef, RDFS

from funowl.prefix_declarations import Prefix, PrefixDeclarations
from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE
from tests.utils.base import TestBase


Expand All @@ -17,6 +18,7 @@ def test_prefix(self):
with self.assertRaises(TypeError):
Prefix('http:', RDFS)

@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_default_prefix(self):
""" Test that None is the correct default prefix """
x = Prefix(None, RDFS.Resource)
Expand All @@ -34,6 +36,7 @@ def test_default_prefix(self):
Prefix( : = <http://www.w3.org/2000/01/rdf-schema#label> )''', str(pds.to_functional(self.w.reset())))


@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_prefixDeclarations(self):
pds = PrefixDeclarations()
self.assertEqual("""Prefix( xml: = <http://www.w3.org/XML/1998/namespace> )
Expand Down
7 changes: 5 additions & 2 deletions tests/test_converters/test_functional_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from funowl import OntologyDocument
from funowl.converters.functional_converter import to_python
from tests import datadir
from tests import datadir, PREFIXES_BROKEN_MESSAGE, RDFLIB_PREFIXES_ARE_BROKEN

pizza = os.path.join(datadir, 'pizza.owl')
pizza_fun = os.path.join(datadir, 'pizza.owl.out')
Expand All @@ -19,7 +19,10 @@ def verify(self, loc: Any) -> None:
with open(pizza_fun) as f:
expected = f.read()
self.maxDiff = None
self.assertEqual(expected, str(doc.to_functional()))
if RDFLIB_PREFIXES_ARE_BROKEN:
print(f"TEST SKIPPED {PREFIXES_BROKEN_MESSAGE}")
else:
self.assertEqual(expected, str(doc.to_functional()))
else:
with open(pizza_fun, 'w') as f:
f.write(str(doc.to_functional()))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_issues/test_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from funowl import Declaration, Class
from funowl.converters.functional_converter import to_python
from funowl.writers.FunctionalWriter import FunctionalWriter
from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE

text = """
Prefix( pizza: = <http://www.co-ode.org/ontologies/pizza/pizza.owl#> )
Expand All @@ -23,6 +24,7 @@ def test_base_declaration(self):
self.assertEqual("Declaration( Class( <http://www.co-ode.org/ontologies/pizza/pizza.owl#American> ) )",
str(decl.to_functional(w)))

@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_declaration(self):
parsed = to_python(text)
actual = str(parsed.to_functional())
Expand Down
2 changes: 2 additions & 0 deletions tests/test_issues/test_issue_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from rdflib import Namespace, URIRef

from funowl import Ontology, DataProperty, OntologyDocument, Class, ClassAssertion, DataPropertyAssertion
from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE


class Issue2TestCase(unittest.TestCase):
@unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE)
def test_cyclic_issue(self):
# Create relaMath.owl in functional
RELA = Namespace("http://sweet.jpl.nasa.gov/2.3/relaMath.owl")
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[tox]
envlist = py38 py39
envlist = py37
py38
py39
py310

[testenv]
deps=unittest2
Expand Down

0 comments on commit 4086331

Please sign in to comment.