Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reproduction system for bug in issue #44 [Caching graph and instance graph differs] * Updated tests * Added incoming change from MyCapytain
- Loading branch information
1 parent
3b65b35
commit 360061d
Showing
9 changed files
with
95 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# IDE | ||
.idea | ||
env | ||
venv | ||
*.rdb | ||
*.autosave | ||
|
||
|
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
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
Empty file.
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,2 @@ | ||
subprocess_repository = ["./tests/test_data/farsiLit"] | ||
subprocess_cache_dir = "cache_dir" |
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,7 @@ | ||
from capitains_nautilus.cts.resolver import NautilusCTSResolver | ||
from werkzeug.contrib.cache import FileSystemCache | ||
from tests.cts.config import subprocess_repository, subprocess_cache_dir | ||
|
||
cache = FileSystemCache(subprocess_cache_dir) | ||
resolver = NautilusCTSResolver(resource=subprocess_repository, cache=cache) | ||
resolver.parse() |
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,70 @@ | ||
from unittest import TestCase | ||
from subprocess import call | ||
from sys import executable | ||
import os | ||
from capitains_nautilus.cts.resolver import NautilusCTSResolver | ||
from werkzeug.contrib.cache import FileSystemCache | ||
from MyCapytain.common.constants import Mimetypes | ||
from tests.cts.config import subprocess_cache_dir, subprocess_repository | ||
|
||
cwd = os.getcwd() | ||
cwd = cwd.replace("tests/cts", "") | ||
python = executable | ||
|
||
|
||
class TestCache(TestCase): | ||
def setUp(self): | ||
output = call([python, "./tests/cts/run_cache.py"], cwd=cwd) | ||
if output != 0: | ||
raise Exception("Creating cache failed") | ||
|
||
self.cache = FileSystemCache(subprocess_cache_dir) | ||
self.resolver = NautilusCTSResolver(resource=subprocess_repository, cache=self.cache) | ||
self.resolver.logger.disabled = True | ||
|
||
def x(*k, **kw): | ||
raise Exception("Parse should not be called") | ||
self.resolver.parse = x | ||
|
||
def tearDown(self): | ||
self.cache.clear() | ||
|
||
def test_argumentless_metadata(self): | ||
inventory = self.resolver.getMetadata() | ||
|
||
self.assertIn( | ||
"Divān (English)", | ||
inventory.export(Mimetypes.XML.CTS), | ||
"Metadata are there" | ||
) | ||
self.assertEqual( | ||
len(inventory.readableDescendants), 4 | ||
) | ||
|
||
def test_first_child(self): | ||
key = list(self.resolver.getMetadata().children.keys())[0] | ||
inventory = self.resolver.getMetadata(key) | ||
|
||
self.assertIn( | ||
"Divān (English)", | ||
inventory.export(Mimetypes.XML.CTS), | ||
"Metadata are there" | ||
) | ||
self.assertEqual( | ||
len(inventory.readableDescendants), 4 | ||
) | ||
|
||
def test_textgroup(self): | ||
""" Found to fail originally because of different GRAPH constant used across modules | ||
(one from the cache vs. the world) """ | ||
inventory = self.resolver.getMetadata("urn:cts:farsiLit:hafez") | ||
|
||
self.assertIn( | ||
"Divān (English)", | ||
inventory.export(Mimetypes.XML.CTS), | ||
"Metadata are there" | ||
) | ||
self.assertEqual( | ||
len(inventory.readableDescendants), 3 | ||
) | ||
|