def test_not_renameable_and_no_new_name_should_not_rename(self):
     from zeit.cms.repository.interfaces import IAutomaticallyRenameable
     content = self.get_content()
     from zeit.cms.checkout.helper import checked_out
     with checked_out(content) as co:
         renameable = IAutomaticallyRenameable(co)
         renameable.renameable = False
     self.assertNotIn('new-name', content.__parent__.keys())
     self.assertIn('testcontent', content.__parent__.keys())
Example #2
0
 def test_article_should_be_renameable(self):
     from zeit.cms.repository.interfaces import IAutomaticallyRenameable
     menu = self.browser.getControl(name='add_menu')
     menu.displayValue = ['Article']
     url = menu.value[0]
     self.browser.open(url)
     article = self.get_article()
     self.assertTrue(IAutomaticallyRenameable(article).renameable)
     self.assertFalse(IAutomaticallyRenameable(article).rename_to)
Example #3
0
File: body.py Project: louika/vivi
def validate_article(context, event):
    # field validation (e.g. zope.schema.Tuple) does type comparisons, which
    # doesn't work with security proxies
    context = zope.security.proxy.removeSecurityProxy(context)
    errors = zope.schema.getValidationErrors(
        zeit.content.article.interfaces.IArticle, context) or []
    # XXX using a separate event handler would be cleaner, but we only support
    # retrieving a single error (last_validation_error), so this doesn't work.
    if (IAutomaticallyRenameable(context).renameable
            and not IAutomaticallyRenameable(context).rename_to):
        errors.append((IAutomaticallyRenameable['rename_to'],
                       zope.schema.interfaces.RequiredMissing('rename_to')))
    if errors:
        event.veto(errors)
Example #4
0
 def test_filename_should_be_editable_when_article_is_renameable(self):
     from zeit.cms.repository.interfaces import IAutomaticallyRenameable
     self.browser.open('Somalia/@@checkout')
     article = self.get_article()
     IAutomaticallyRenameable(article).renameable = True
     self.browser.open('@@edit.form.new-filename?show_form=yes')
     ctrl = self.browser.getControl('New file name')
     self.assertEqual('', ctrl.value)
Example #5
0
 def should_exclude(self, content):
     renameable = getattr(IAutomaticallyRenameable(content, None),
                          'renameable', False)
     if renameable:
         return True
     for exclude in self.excludes:
         if self._matches(exclude, content):
             log.debug('Skipping %s, matched exclude %s', content, exclude)
             return True
     return False
Example #6
0
 def test_existing_filename_yields_error_message(self):
     article = Article()
     IAutomaticallyRenameable(article).renameable = True
     self.repository['online']['2007']['01']['article'] = article
     b = self.browser
     b.open('http://localhost/++skin++vivi/repository'
            '/online/2007/01/article/@@checkout')
     b.open('@@edit.form.new-filename?show_form=1')
     b.getControl('New file name').value = 'Somalia'
     b.getControl('Apply').click()
     self.assertEllipsis('...Somalia...already exists...', b.contents)
 def test_renameable_should_be_none_after_rename(self):
     from zeit.cms.repository.interfaces import IAutomaticallyRenameable
     content = self.get_content()
     from zeit.cms.checkout.helper import checked_out
     with checked_out(content) as co:
         renameable = IAutomaticallyRenameable(co)
         renameable.renameable = True
         renameable.rename_to = u'new-name'
     content = self.get_content('new-name')
     renameable = IAutomaticallyRenameable(content)
     # Test for None as this is the value which we get when the DAV property
     # does not exist. And thats what we really want.
     self.assertIsNone(renameable.renameable)
     self.assertIsNone(renameable.rename_to)
Example #8
0
 def test_skip_auto_renameable(self):
     hook = zeit.cms.checkout.webhook.Hook(None)
     self.assertFalse(hook.should_exclude(self.repository['testcontent']))
     with checked_out(self.repository['testcontent']) as co:
         IAutomaticallyRenameable(co).renameable = True
     self.assertTrue(hook.should_exclude(self.repository['testcontent']))
Example #9
0
 def is_new(self):
     return IAutomaticallyRenameable(self.context).renameable
Example #10
0
 def test_content_should_not_be_automatically_renameable_by_default(self):
     from zeit.cms.repository.interfaces import IAutomaticallyRenameable
     self.assertFalse(
         IAutomaticallyRenameable(self.get_content()).renameable)