[Checkins] SVN: z3c.table/branches/lazyvalues/src/z3c/table/ move miscellaneous
Godefroid Chapelle
gotcha at bubblenet.be
Wed Jul 7 09:58:33 EDT 2010
Log message for revision 114287:
move miscellaneous
Changed:
U z3c.table/branches/lazyvalues/src/z3c/table/README.txt
A z3c.table/branches/lazyvalues/src/z3c/table/miscellaneous.txt
U z3c.table/branches/lazyvalues/src/z3c/table/tests.py
-=-
Modified: z3c.table/branches/lazyvalues/src/z3c/table/README.txt
===================================================================
--- z3c.table/branches/lazyvalues/src/z3c/table/README.txt 2010-07-07 13:34:36 UTC (rev 114286)
+++ z3c.table/branches/lazyvalues/src/z3c/table/README.txt 2010-07-07 13:58:33 UTC (rev 114287)
@@ -638,103 +638,3 @@
-Miscellaneous
--------------
-
-Make coverage report happy and test different things.
-
-Test if the getWeight method returns 0 (zero) on AttributeError:
-
- >>> from z3c.table.table import getWeight
- >>> getWeight(None)
- 0
-
-Try to call a simple table and call renderBatch which should return an empty
-string:
-
- >>> simpleTable = table.Table(container, request)
- >>> simpleTable.renderBatch()
- u''
-
-Try to render an empty table adapting an empty mapping:
-
- >>> simpleTable = table.Table({}, request)
- >>> simpleTable.render()
- u''
-
-Since we have registered 3 adapters for IColumn on None (IOW on an empty mapping),
-initializing rows definitions for the empty table will initiliaze the columns attribute list
-
- >>> simpleTable.columns
-
- >>> simpleTable.initColumns()
- >>> simpleTable.columns
- [<CorrectColspanColumn u'colspanColumn'>, <NameColumn u'secondColumn'>, <TitleColumn u'firstColumn'>]
-
-Rendering the empty table now return the string:
-
- >>> print simpleTable.render()
- <table>
- <thead>
- <tr>
- <th>Colspan</th>
- <th><a href="?table-sortOrder=ascending&table-sortOn=table-secondColumn-1" title="Sort">Name</a></th>
- <th><a href="?table-sortOrder=ascending&table-sortOn=table-firstColumn-2" title="Sort">Title</a></th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
-
-
-Let's see if the addColumn raises a ValueError if there is no Column class:
-
- >>> column.addColumn(simpleTable, column.Column, u'dummy')
- <Column u'dummy'>
-
- >>> column.addColumn(simpleTable, None, u'dummy')
- Traceback (most recent call last):
- ...
- ValueError: class_ None must implement IColumn.
-
-Test if we can set additional kws in addColumn:
-
- >>> simpleColumn = column.addColumn(simpleTable, column.Column, u'dummy',
- ... foo='foo value', bar=u'something else', counter=99)
- >>> simpleColumn.foo
- 'foo value'
-
- >>> simpleColumn.bar
- u'something else'
-
- >>> simpleColumn.counter
- 99
-
-The NoneCell class provides some methods which never get. But this methods must
-be there because the interfaces defines them. Let's test the default values
-and make coverage report happy.
-
-Let's get an container item first:
-
- >>> firstItem = container[u'first']
- >>> noneCellColumn = column.addColumn(simpleTable, column.NoneCell, u'none')
- >>> noneCellColumn.renderCell(firstItem)
- u''
-
- >>> noneCellColumn.getColspan(firstItem)
- 0
-
- >>> noneCellColumn.renderHeadCell()
- u''
-
- >>> noneCellColumn.renderCell(firstItem)
- u''
-
-The default ``Column`` implementation raises an NotImplementedError if we
-do not override the renderCell method:
-
- >>> defaultColumn = column.addColumn(simpleTable, column.Column, u'default')
- >>> defaultColumn.renderCell(firstItem)
- Traceback (most recent call last):
- ...
- NotImplementedError: Subclass must implement renderCell
Added: z3c.table/branches/lazyvalues/src/z3c/table/miscellaneous.txt
===================================================================
--- z3c.table/branches/lazyvalues/src/z3c/table/miscellaneous.txt (rev 0)
+++ z3c.table/branches/lazyvalues/src/z3c/table/miscellaneous.txt 2010-07-07 13:58:33 UTC (rev 114287)
@@ -0,0 +1,116 @@
+Miscellaneous
+-------------
+
+Make coverage report happy and test different things.
+
+Test if the getWeight method returns 0 (zero) on AttributeError:
+
+ >>> from z3c.table.table import getWeight
+ >>> getWeight(None)
+ 0
+
+Create a container:
+
+ >>> from z3c.table.testing import Container
+ >>> container = Container()
+
+Try to call a simple table and call renderBatch which should return an empty
+string:
+
+ >>> from z3c.table import table
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+ >>> simpleTable = table.Table(container, request)
+ >>> simpleTable.renderBatch()
+ u''
+
+Try to render an empty table adapting an empty mapping:
+
+ >>> simpleTable = table.Table({}, request)
+ >>> simpleTable.render()
+ u''
+
+Since we register an adapter for IColumn on None (IOW on an empty mapping).
+
+ >>> from zope.component import provideAdapter
+ >>> from z3c.table import column
+ >>> from z3c.table import interfaces
+ >>> provideAdapter(column.NameColumn,
+ ... (None, None, interfaces.ITable), provides=interfaces.IColumn,
+ ... name='secondColumn')
+
+Initializing rows definitions for the empty table initializes the columns
+attribute list.
+
+ >>> simpleTable.columns
+
+ >>> simpleTable.initColumns()
+ >>> simpleTable.columns
+ [<NameColumn u'secondColumn'>]
+
+Rendering the empty table now return the string:
+
+ >>> print simpleTable.render()
+ <table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ </table>
+
+
+Let's see if the addColumn raises a ValueError if there is no Column class:
+
+ >>> column.addColumn(simpleTable, column.Column, u'dummy')
+ <Column u'dummy'>
+
+ >>> column.addColumn(simpleTable, None, u'dummy')
+ Traceback (most recent call last):
+ ...
+ ValueError: class_ None must implement IColumn.
+
+Test if we can set additional kws in addColumn:
+
+ >>> simpleColumn = column.addColumn(simpleTable, column.Column, u'dummy',
+ ... foo='foo value', bar=u'something else', counter=99)
+ >>> simpleColumn.foo
+ 'foo value'
+
+ >>> simpleColumn.bar
+ u'something else'
+
+ >>> simpleColumn.counter
+ 99
+
+The NoneCell class provides some methods which never get called. But these
+are defined in the interface. Let's test the default values
+and make coverage report happy.
+
+Let's get an container item first:
+
+ >>> from z3c.table.testing import Content
+ >>> firstItem = Content('First', 1)
+ >>> noneCellColumn = column.addColumn(simpleTable, column.NoneCell, u'none')
+ >>> noneCellColumn.renderCell(firstItem)
+ u''
+
+ >>> noneCellColumn.getColspan(firstItem)
+ 0
+
+ >>> noneCellColumn.renderHeadCell()
+ u''
+
+ >>> noneCellColumn.renderCell(firstItem)
+ u''
+
+The default ``Column`` implementation raises an NotImplementedError if we
+do not override the renderCell method:
+
+ >>> defaultColumn = column.addColumn(simpleTable, column.Column, u'default')
+ >>> defaultColumn.renderCell(firstItem)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Subclass must implement renderCell
Modified: z3c.table/branches/lazyvalues/src/z3c/table/tests.py
===================================================================
--- z3c.table/branches/lazyvalues/src/z3c/table/tests.py 2010-07-07 13:34:36 UTC (rev 114286)
+++ z3c.table/branches/lazyvalues/src/z3c/table/tests.py 2010-07-07 13:58:33 UTC (rev 114287)
@@ -165,6 +165,10 @@
setUp=testing.setUp, tearDown=testing.tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS|doctest.REPORT_UDIFF,
),
+ doctest.DocFileSuite('miscellaneous.txt',
+ setUp=testing.setUp, tearDown=testing.tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
doctest.DocFileSuite('column.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
More information about the checkins
mailing list