Skip to content

Commit

Permalink
Merge pull request #125 from Capitains/issue-124
Browse files Browse the repository at this point in the history
Fixed issue-124
  • Loading branch information
sonofmun committed Apr 20, 2017
2 parents e0bad2a + 8fb232b commit c255ddc
Show file tree
Hide file tree
Showing 7 changed files with 6,944 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MyCapytain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""

__version__ = "2.0.0b18"
__version__ = "2.0.0b19"
2 changes: 1 addition & 1 deletion MyCapytain/resources/texts/locals/tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def __findCRefPattern(self, xml):
:return: None
"""
if self.citation.isEmpty():
citation = xml.xpath("//tei:refsDecl[@n='CTS']", namespaces=NS),
citation = xml.xpath("//tei:refsDecl[@n='CTS']", namespaces=NS)
if len(citation):
self.citation = Citation.ingest(resource=citation[0], xpath=".//tei:cRefPattern")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ def test_complex_reffs(self):
"""
self.assertEqual(("pr.1" in list(map(lambda x: str(x), self.text_complex.reffs))), True)

def test_xml_no_refs_Decl(self):
""" Test the result of parsing when there is no citation """
text = self.parse("tests/testing_data/texts/refsDeclButNoCTS.xml")
self.assertEqual(
text.citation.isEmpty(), True, "There should be no citation"
)


def test_urn(self):
""" Test setters and getters for urn """

Expand Down
9 changes: 8 additions & 1 deletion tests/resources/texts/locals/test_capitains_xml_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import MyCapytain.errors
import MyCapytain.resources.texts.encodings
import MyCapytain.resources.texts.locals.tei
from tests.resources.commonTests import CapitainsXmlTextTest, CapitainsXmlPassageTests, CapitainsXMLRangePassageTests
from tests.resources.texts.locals.commonTests import CapitainsXmlTextTest, CapitainsXmlPassageTests, CapitainsXMLRangePassageTests


class TestLocalXMLTextImplementation(CapitainsXmlTextTest, unittest.TestCase, xmlunittest.XmlTestMixin):
Expand All @@ -37,6 +37,13 @@ def setUp(self):
resource=f
)

def parse(self, file):
with open(file) as f:
text = MyCapytain.resources.texts.locals.tei.Text(
resource=f
)
return text

def tearDown(self):
self.text.close()

Expand Down
14 changes: 12 additions & 2 deletions tests/resources/texts/locals/test_capitains_xml_notObjectified.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import xmlunittest
from lxml import etree

from MyCapytain.common.utils import xmlparser
import MyCapytain.common.reference
import MyCapytain.errors
import MyCapytain.resources.texts.encodings
import MyCapytain.resources.texts.locals.tei
from tests.resources.commonTests import CapitainsXmlTextTest, CapitainsXmlPassageTests, CapitainsXMLRangePassageTests
from MyCapytain.common.utils import xmlparser
from tests.resources.texts.locals.commonTests import CapitainsXmlTextTest, CapitainsXmlPassageTests, CapitainsXMLRangePassageTests


objectifiedParser = lambda x: xmlparser(x, objectify=False)
Expand Down Expand Up @@ -40,6 +40,16 @@ def setUp(self):
resource=objectifiedParser(f)
)

self.cls = lambda x: MyCapytain.resources.texts.locals.tei.Text(resource=objectifiedParser(x))

def parse(self, file):
with open(file) as f:
text = MyCapytain.resources.texts.locals.tei.Text(
resource=objectifiedParser(f)
)
return text


def tearDown(self):
self.text.close()

Expand Down
2 changes: 1 addition & 1 deletion tests/resources/texts/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ def test_exportable_capacities(self):
P.export_capacities,
[Mimetypes.PYTHON.ETREE, Mimetypes.XML.Std, Mimetypes.PYTHON.NestedDict, Mimetypes.PLAINTEXT, Mimetypes.XML.TEI],
"Passage should be able to export to given resources"
)
)
6,913 changes: 6,913 additions & 0 deletions tests/testing_data/texts/refsDeclButNoCTS.xml

Large diffs are not rendered by default.

0 comments on commit c255ddc

Please sign in to comment.