-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a possibilty to copy the ontology
This is done by saving it in a temporary file and loading it as new.
- Loading branch information
1 parent
12ff93a
commit 37a0449
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import TYPE_CHECKING | ||
import pytest | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def test_copy(testonto: "Ontology", repo_dir: "Path") -> None: | ||
"""Test adding entities to ontology""" | ||
|
||
from ontopy import get_ontology | ||
from ontopy.utils import NoSuchLabelError | ||
|
||
# create new reference to ontology | ||
testonto = get_ontology( | ||
repo_dir / "tests" / "testonto" / "testonto.ttl" | ||
).load() | ||
testonto_ref = testonto | ||
|
||
# add new entity to ontology | ||
testonto.new_entity("FantasyClass", testonto.TestClass) | ||
|
||
assert testonto_ref.FantasyClass == testonto.FantasyClass | ||
|
||
# make a copy and check that new entity in original is not in copy | ||
testonto_copy = testonto.copy() | ||
|
||
testonto.new_entity("FantasyClass2", testonto_copy.TestClass) | ||
|
||
assert testonto.FantasyClass2 | ||
|
||
with pytest.raises(NoSuchLabelError): | ||
assert testonto_copy.FantasyClass2 |