Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
kupu.plone.tests.test_librarymanager.TestILibraryManager Class Reference

List of all members.

Public Member Functions

def afterSetUp
def makeLibraries
def test_get_library
def test_expressions
def test_delete
def test_update
def test_move

Public Attributes

 libs
 portal
 context

Detailed Description

Test the implementation of ILibraryManger in KupuLibraryTool

Definition at line 39 of file test_librarymanager.py.


Member Function Documentation

Definition at line 42 of file test_librarymanager.py.

00042 
00043     def afterSetUp(self):
00044         self.libs = self.makeLibraries()

Definition at line 45 of file test_librarymanager.py.

00045 
00046     def makeLibraries(self):
00047         # need to use Plone specific tool for Acquisition. Sucks.
00048         libs = PloneKupuLibraryTool()
00049         self.portal = FakePortal()
00050         context = FakeContextObject()
00051         libs = libs.__of__(self.portal)
00052         self.context = context.__of__(self.portal)
00053         libs.addLibrary('foo_id', 'Foobar', 'foobar', 'foosrc', 'fooicon')
00054         libs.addLibrary('bar_id', 'Barfoo', 'barfoo', 'barsrc', 'baricon')
00055         libs.addLibrary('baz_id', 'Baz', 'foobarbaz', 'bazsrc', 'bazicon')
00056         return libs

Here is the caller graph for this function:

Definition at line 93 of file test_librarymanager.py.

00093 
00094     def test_delete(self):
00095         libs = self.libs
00096         libs.deleteLibraries([1])
00097         expected = (
00098             dict(id='foo_id', title='Foobar', uri='foobar',
00099                  src='foosrc', icon='fooicon'),
00100             dict(id='baz_id', title='Baz', uri='foobarbaz',
00101                  src='bazsrc', icon='bazicon'),
00102             )
00103         self.assertEqual(libs.getLibraries(self.context), expected)
00104 
00105         libs = self.makeLibraries()
00106         libs.deleteLibraries([0, 1])
00107         expected = (
00108             dict(id='baz_id', title='Baz', uri='foobarbaz',
00109                  src='bazsrc', icon='bazicon'),
00110             )
00111         self.assertEqual(libs.getLibraries(self.context), expected)

Here is the call graph for this function:

Definition at line 69 of file test_librarymanager.py.

00069 
00070     def test_expressions(self):
00071         libs = self.libs
00072         context = self.context
00073         new_libs = (
00074             dict(id='foo_id', title='Foobar', uri='python:42',
00075                  src='foosrc', icon='fooicon'),
00076             dict(id='bar_id', title='Barfoo', uri='python:object',
00077                  src='barsrc', icon='baricon'),
00078             dict(id='baz_id', title='Baz', uri='string:${object/absolute_url}',
00079                  src='bazsrc', icon='bazicon'),
00080             )
00081         libs.updateLibraries(new_libs)
00082 
00083         expected = (
00084             dict(id='foo_id', title='Foobar', uri=42,
00085                  src='foosrc', icon='fooicon'),
00086             dict(id='bar_id', title='Barfoo', uri=context,
00087                  src='barsrc', icon='baricon'),
00088             dict(id='baz_id', title='Baz', uri=u"The answer is 42",
00089                  src='bazsrc', icon='bazicon')
00090             )
00091         v = libs.getLibraries(context)
00092         self.assertEqual(v, expected)

Here is the call graph for this function:

Definition at line 57 of file test_librarymanager.py.

00057 
00058     def test_get_library(self):
00059         libs = self.libs
00060         expected = (
00061             dict(id='foo_id', title='Foobar', uri='foobar',
00062                  src='foosrc', icon='fooicon'),
00063             dict(id='bar_id', title='Barfoo', uri='barfoo',
00064                  src='barsrc', icon='baricon'),
00065             dict(id='baz_id', title='Baz', uri='foobarbaz',
00066                  src='bazsrc', icon='bazicon'),
00067             )
00068         self.assertEqual(libs.getLibraries(self.context), expected)

Here is the call graph for this function:

Definition at line 132 of file test_librarymanager.py.

00132 
00133     def test_move(self):
00134         libs = self.libs
00135         libs.moveUp([1])
00136         expected = (
00137             dict(id='bar_id', title='Barfoo', uri='barfoo',
00138                  src='barsrc', icon='baricon'),
00139             dict(id='foo_id', title='Foobar', uri='foobar',
00140                  src='foosrc', icon='fooicon'),
00141             dict(id='baz_id', title='Baz', uri='foobarbaz',
00142                  src='bazsrc', icon='bazicon'),
00143             )
00144         self.assertEqual(libs.getLibraries(self.context), expected)
00145 
00146         libs.moveDown([1])
00147         expected = (
00148             dict(id='bar_id', title='Barfoo', uri='barfoo',
00149                  src='barsrc', icon='baricon'),
00150             dict(id='baz_id', title='Baz', uri='foobarbaz',
00151                  src='bazsrc', icon='bazicon'),
00152             dict(id='foo_id', title='Foobar', uri='foobar',
00153                  src='foosrc', icon='fooicon'),
00154             )
00155         self.assertEqual(libs.getLibraries(self.context), expected)
00156 
00157         libs.moveUp([1, 2])
00158         expected = (
00159             dict(id='baz_id', title='Baz', uri='foobarbaz',
00160                  src='bazsrc', icon='bazicon'),
00161             dict(id='foo_id', title='Foobar', uri='foobar',
00162                  src='foosrc', icon='fooicon'),
00163             dict(id='bar_id', title='Barfoo', uri='barfoo',
00164                  src='barsrc', icon='baricon'),
00165             )
00166         self.assertEqual(libs.getLibraries(self.context), expected)
00167 
00168         libs.moveDown([2])
00169         expected = (
00170             dict(id='bar_id', title='Barfoo', uri='barfoo',
00171                  src='barsrc', icon='baricon'),
00172             dict(id='foo_id', title='Foobar', uri='foobar',
00173                  src='foosrc', icon='fooicon'),
00174             dict(id='baz_id', title='Baz', uri='foobarbaz',
00175                  src='bazsrc', icon='bazicon'),
00176             )
00177         self.assertEqual(libs.getLibraries(self.context), expected)

Here is the call graph for this function:

Definition at line 112 of file test_librarymanager.py.

00112 
00113     def test_update(self):
00114         libs = self.libs
00115         context = self.context
00116         new_libs = (
00117             dict(id='foo_new_id', title='Newfoo', uri="python:object",
00118                  src='foonewsrc', icon="foonewicon"),
00119             dict(id='just_a_new_id'),
00120             dict(src="python:'you stink'.upper()"),
00121             )
00122         libs.updateLibraries(new_libs)
00123         expected = (
00124             dict(id='foo_new_id', title='Newfoo', uri=context,
00125                  src='foonewsrc', icon='foonewicon'),
00126             dict(id='just_a_new_id', title='Barfoo', uri='barfoo',
00127                  src='barsrc', icon='baricon'),
00128             dict(id='baz_id', title='Baz', uri='foobarbaz',
00129                  src="YOU STINK", icon='bazicon'),
00130             )
00131         self.assertEqual(libs.getLibraries(context), expected)

Here is the call graph for this function:


Member Data Documentation

Definition at line 51 of file test_librarymanager.py.

Definition at line 43 of file test_librarymanager.py.

Definition at line 48 of file test_librarymanager.py.


The documentation for this class was generated from the following file: