Skip to content

Commit

Permalink
Added PTCycleTest & PmlMaxHeightMixInTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuluPro committed Sep 26, 2015
1 parent 99574f8 commit cb175ae
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_reportlab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import unittest
from xhtml2pdf import xhtml2pdf_reportlab


class PTCycleTest(unittest.TestCase):
def test_init(self):
xhtml2pdf_reportlab.PTCycle()

def test_cyclicIterator(self):
ptcycle = xhtml2pdf_reportlab.PTCycle()
ptcycle.extend(range(10))
for ele in ptcycle:
pass


class PmlMaxHeightMixInTest(unittest.TestCase):
def test_setMaxHeight_height_lt_70000(self):
pmlmaxheightmixin = xhtml2pdf_reportlab.PmlMaxHeightMixIn()
pmlmaxheightmixin.setMaxHeight(69999)

# def test_setMaxHeight_height_lt_70000_and_canv(self):
# pmlmaxheightmixin = xhtml2pdf_reportlab.PmlMaxHeightMixIn()
# pmlmaxheightmixin.setMaxHeight(69999)

# def test_setMaxHeight_height_lt_70000_and_canv_with_height(self):
# pmlmaxheightmixin = xhtml2pdf_reportlab.PmlMaxHeightMixIn()
# pmlmaxheightmixin.setMaxHeight(69999)

def test_setMaxHeight_height_gte_70000(self):
pmlmaxheightmixin = xhtml2pdf_reportlab.PmlMaxHeightMixIn()
pmlmaxheightmixin.setMaxHeight(70000)

def test_getMaxHeight(self):
pmlmaxheightmixin = xhtml2pdf_reportlab.PmlMaxHeightMixIn()
self.assertEqual(0, pmlmaxheightmixin.getMaxHeight())
pmlmaxheightmixin.availHeightValue = 42
self.assertEqual(42, pmlmaxheightmixin.getMaxHeight())


if __name__ == "__main__":
unittest.main()
2 changes: 2 additions & 0 deletions xhtml2pdf/xhtml2pdf_reportlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ def setMaxHeight(self, availHeight):
self.availHeightValue = self.canv.maxAvailHeightValue = max(
availHeight,
self.canv.maxAvailHeightValue)
# TODO: Useless condition
else:
self.availHeightValue = availHeight
# TODO: availHeightValue is set above
if not hasattr(self, "availHeightValue"):
self.availHeightValue = 0
return self.availHeightValue
Expand Down

0 comments on commit cb175ae

Please sign in to comment.