Esempio n. 1
0
    def test_container_site(self):
        sm = SiteManagerStub()
        futurama = self.futurama
        omicronpersei = self.futurama['omicronpersei']

        # test behaviour before and after setting a site
        adapter = IChildObjects(futurama)
        self.assertTrue(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), list(futurama.values()))
        futurama.setSiteManager(sm)
        self.assertIn(sm, adapter.getChildObjects())

        adapter = IChildObjects(omicronpersei)
        self.assertFalse(adapter.hasChildren())
        omicronpersei.setSiteManager(sm)
        self.assertTrue(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), [sm])
Esempio n. 2
0
    def test_container_site(self):
        sm = SiteManagerStub()
        futurama = self.futurama
        omicronpersei = self.futurama["omicronpersei"]

        # test behaviour before and after setting a site
        adapter = IChildObjects(futurama)
        self.assert_(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), futurama.values())
        futurama.setSiteManager(sm)
        self.assert_(sm in adapter.getChildObjects())

        adapter = IChildObjects(omicronpersei)
        self.failIf(adapter.hasChildren())
        omicronpersei.setSiteManager(sm)
        self.assert_(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), [sm])
Esempio n. 3
0
    def test_container_childobjects(self):
        # test container with children
        futurama = self.futurama
        adapter = IChildObjects(futurama)
        self.assert_(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), futurama.values())

        # test acquired container with children
        planetexpress = self.futurama["planetexpress"]
        adapter = IChildObjects(planetexpress)
        self.assert_(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), planetexpress.values())

        # test acquired container w/o children
        omicronpersei = self.futurama["omicronpersei"]
        adapter = IChildObjects(omicronpersei)
        self.failIf(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), [])
Esempio n. 4
0
    def test_container_childobjects(self):
        # test container with children
        futurama = self.futurama
        adapter = IChildObjects(futurama)
        self.assertTrue(adapter.hasChildren())
        self.assertEqual(list(adapter.getChildObjects()),
                         list(futurama.values()))

        # test acquired container with children
        planetexpress = self.futurama['planetexpress']
        adapter = IChildObjects(planetexpress)
        self.assertTrue(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(),
                         list(planetexpress.values()))

        # test acquired container w/o children
        omicronpersei = self.futurama['omicronpersei']
        adapter = IChildObjects(omicronpersei)
        self.assertFalse(adapter.hasChildren())
        self.assertEqual(adapter.getChildObjects(), [])