def setUp(self): from avrc.theme.leadtheway.browser.viewlets import SlideshowViewlet portal = self.layer['portal'] request = self.layer['request'] self.homepage_viewlet = SlideshowViewlet(portal, request, None, None) setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Document', 'page', title=u"Page 1") setRoles(portal, TEST_USER_ID, ['Anonymous']) self.subpage_viewlet = SlideshowViewlet(portal['page'], request, None, None)
class TestViewlet(unittest.TestCase): layer= LEADTHEWAY_THEME_INTEGRATION_TESTING def setUp(self): from avrc.theme.leadtheway.browser.viewlets import SlideshowViewlet portal = self.layer['portal'] request = self.layer['request'] self.homepage_viewlet = SlideshowViewlet(portal, request, None, None) setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Document', 'page', title=u"Page 1") setRoles(portal, TEST_USER_ID, ['Anonymous']) self.subpage_viewlet = SlideshowViewlet(portal['page'], request, None, None) def tearDown(self): portal = self.layer['portal'] del self.homepage_viewlet del self.subpage_viewlet del portal['page'] def test_viewlet_container(self): portal = self.layer['portal'] self.assertEquals(None, self.homepage_viewlet.slideshowContainer()) setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Folder', 'slideshow') setRoles(portal, TEST_USER_ID, ['Anonymous']) self.assertEquals(portal.restrictedTraverse('slideshow'), self.homepage_viewlet.slideshowContainer()) def test_home_check(self): self.assertTrue(self.homepage_viewlet.isHomePage(), 'This fails because the testing sets the default view to folder_listing') self.assertFalse(self.subpage_viewlet.isHomePage()) def test_slideshow_images(self): ## We will need a slideshow container portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Folder', 'slideshow') slideshow_container = portal['slideshow'] for img in ['1.png','2.png', '3.png']: slideshow_container.invokeFactory('Image', img) setRoles(portal, TEST_USER_ID, ['Anonymous']) self.assertEqual(3, len(self.homepage_viewlet.slideshowImages())) del portal['slideshow'] def test_mosaic_images(self): portal = self.layer['portal'] imagelist = self.subpage_viewlet.mosaicImages() self.assertEqual(16, len(imagelist))