def test_body_set_update(self): self._populate_special(self._obj) context = DummySetupEnviron() context._should_purge = False adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = _CATALOG_UPDATE_BODY self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML))
def test_body_set_update(self): # Assert that the catalog ends up the way we expect it to. self._populate_special(self._obj) context = DummySetupEnviron() context._should_purge = False adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = _CATALOG_UPDATE_BODY self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML, ''))
def test_body_set_update(self): # Assert that the catalog ends up the way we expect it to. self._populate_special(self._obj) context = DummySetupEnviron() context._should_purge = False adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = _CATALOG_UPDATE_BODY self.assertEqual(adapted.body, _CATALOG_BODY % ("", _ZCTEXT_XML, ""))
def test_body_set_update(self): # Assert that the catalog ends up the way we expect it to. self._populate_special(self._obj) context = DummySetupEnviron() context._should_purge = False adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = _CATALOG_UPDATE_BODY self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML, '')) message = self.getLastMessage() self.assertEqual( message[-1], "foo_catalog:['eggs', 'spam']", "Not updated columns in catalog" )
def test_no_overwrite(self): # make sure we don't overwrite an existing tool when it # already exists and has the same factory context = DummySetupEnviron() context._should_purge = False importer = getMultiAdapter((self._obj, context), IBody) importer.body = self._BODY # <-- triggers the import :( util = queryUtility(IDummyInterface) value = 'bar' util.foo = value # re-retrieve to make sure it's the same object util = queryUtility(IDummyInterface) self.assertEquals(getattr(util, 'foo', None), value) context = DummySetupEnviron() context._should_purge = False importer = getMultiAdapter((self._obj, context), IBody) importer.body = self._BODY # <-- triggers the import :( util = queryUtility(IDummyInterface) self.assertEquals(getattr(util, 'foo', None), value)
def test_body_set(self): context = DummySetupEnviron() adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = self._BODY self._verifyImport(self._obj) self.assertEqual(adapted.body, self._BODY) # now in update mode context._should_purge = False adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = self._BODY self._verifyImport(self._obj) self.assertEqual(adapted.body, self._BODY) # and again in update mode adapted = getMultiAdapter((self._obj, context), IBody) adapted.body = self._BODY self._verifyImport(self._obj) self.assertEqual(adapted.body, self._BODY)
def test_blacklist_set(self): obj = self._obj # Register our blacklist gsm = getGlobalSiteManager() gsm.registerUtility(DummyBlacklist(), IComponentsHandlerBlacklist, name=u'dummy') context = DummySetupEnviron() adapted = getMultiAdapter((obj, context), IBody) adapted.body = self._BODY util = queryUtility(IDummyInterface2, name=u'foo') self.failUnless(IDummyInterface.providedBy(util)) self.failUnless(util.verify()) util = queryUtility(IDummyInterface) self.failUnless(util is None) # now in update mode context._should_purge = False adapted = getMultiAdapter((obj, context), IBody) adapted.body = self._BODY util = queryUtility(IDummyInterface2, name=u'foo') self.failUnless(IDummyInterface.providedBy(util)) self.failUnless(util.verify()) util = queryUtility(IDummyInterface) self.failUnless(util is None) # and again in update mode adapted = getMultiAdapter((obj, context), IBody) adapted.body = self._BODY util = queryUtility(IDummyInterface2, name=u'foo') self.failUnless(IDummyInterface.providedBy(util)) self.failUnless(util.verify()) util = queryUtility(IDummyInterface) self.failUnless(util is None)