def test_form_enforces_parent_doc_to_exist(self): form = TreeMoveForm({'locale': 'en-US', 'title': 'Article', 'slug': 'nothing/article'}) form.is_valid() ok_(form.errors) ok_(u'Parent' in form.errors.as_text()) ok_(u'does not exist' in form.errors.as_text())
def test_form_properly_strips_leading_cruft(self): """ Tests that leading slash and {locale}/docs/ is removed if included """ comparisons = [ ['/somedoc', 'somedoc'], # leading slash ['/en-US/docs/mynewplace', 'mynewplace'], # locale and docs ['/docs/one', 'one'], # leading docs ['docs/one', 'one'], # leading docs without slash ['fr/docs/one', 'one'], # foreign locale with docs ['docs/article-title/docs', 'article-title/docs'] # docs with later docs ] for comparison in comparisons: form = TreeMoveForm({'locale': 'en-US', 'title': 'Article', 'slug': comparison[0]}) form.is_valid() eq_(comparison[1], form.cleaned_data['slug'])