Skip to content

Commit

Permalink
Added tests for DTD and reference generator. Also removed some dead c…
Browse files Browse the repository at this point in the history
…ode.
  • Loading branch information
strichter committed Dec 21, 2012
1 parent 9a21260 commit 356ae82
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 80 deletions.
4 changes: 0 additions & 4 deletions src/z3c/rml/dtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,3 @@ def generate(useWrapper=False):

def main():
print generate()


if __name__ == '__main__':
print main()
42 changes: 0 additions & 42 deletions src/z3c/rml/error.py

This file was deleted.

8 changes: 2 additions & 6 deletions src/z3c/rml/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def extractExamples(directory):
return examples


def main():
def main(outPath=None):
examples = extractExamples(EXAMPLES_DIRECTORY)

template = pagetemplate.RMLPageTemplateFile('reference.pt')
Expand All @@ -241,8 +241,4 @@ def main():
directives = sorted(directives.values(), key=lambda d: d['name'])

pdf = template(types=getAttributeTypes(), directives=directives)
open('rml-reference.pdf', 'wb').write(pdf)


if __name__ == '__main__':
main()
open(outPath or 'rml-reference.pdf', 'wb').write(pdf)
Binary file modified src/z3c/rml/rml-reference.pdf
Binary file not shown.
1 change: 0 additions & 1 deletion src/z3c/rml/rml.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -2205,4 +2205,3 @@
<!ELEMENT plugInGraphic (#PCDATA)>
<!ATTLIST plugInGraphic module CDATA #REQUIRED>
<!ATTLIST plugInGraphic function CDATA #REQUIRED>

27 changes: 0 additions & 27 deletions src/z3c/rml/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,6 @@ def process(self):
manager.names[id] = value


class IGetName(interfaces.IRMLDirectiveSignature):
"""Get the text for the id."""

id = attr.String(
title=u'Id',
description=u'The id as which the value is known.',
required=True)

class GetName(directive.RMLDirective):
signature = IGetName

def process(self):
id = dict(self.getAttributeValues()).pop('id')
manager = attr.getManager(self)
try:
text = manager.names[id] + (self.element.tail or u'')
except:
import pdb; pdb.set_trace()
# Now replace the element with the text
parent = self.element.getparent()
if parent.text is None:
parent.text = text
else:
parent.text += text
parent.remove(self.element)


class IAlias(interfaces.IRMLDirectiveSignature):
"""Defines an alias for a given style."""

Expand Down
31 changes: 31 additions & 0 deletions src/z3c/rml/tests/test_dtd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
##############################################################################
#
# Copyright (c) 2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTLAR PURPOSE.
#
##############################################################################
"""Test generating DTD
"""
import os
import unittest
from z3c.rml import dtd

class DTDTestCase(unittest.TestCase):

level = 2

def runTest(self):
path = os.path.join(os.path.dirname(dtd.__file__), 'rml.dtd')
with open(path, 'w') as file:
file.write(dtd.generate())


def test_suite():
return unittest.TestSuite([DTDTestCase()])
31 changes: 31 additions & 0 deletions src/z3c/rml/tests/test_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
##############################################################################
#
# Copyright (c) 2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTLAR PURPOSE.
#
##############################################################################
"""Test generating reference.
"""
import os
import unittest
from z3c.rml import reference

class ReferenceTestCase(unittest.TestCase):

level = 3

def runTest(self):
reference.main(
os.path.join(os.path.dirname(reference.__file__),
'rml-reference.pdf'))


def test_suite():
return unittest.TestSuite([ReferenceTestCase()])

0 comments on commit 356ae82

Please sign in to comment.