def test_check_host(self): from_url = Document.from_url d_en = DocumentFactory(locale='en-US', title=u'How to delete Google Chrome?') sumo_host = 'http://support.mozilla.org' invalid_url = urlparse.urljoin(sumo_host, d_en.get_absolute_url()) self.assertIsNone(from_url(invalid_url)) self.assertEqual(d_en, from_url(invalid_url, check_host=False))
def test_id_only(self): from_url = Document.from_url d = DocumentFactory(locale='en-US', title=u'How to delete Google Chrome?') doc = from_url(d.get_absolute_url(), id_only=True) self.assertEqual(d.title, doc.title) self.assertEqual(d.locale, doc.locale)
def test_check_host(self): from_url = Document.from_url d_en = DocumentFactory(locale='en-US', title=u'How to delete Google Chrome?') sumo_host = 'https://support.mozilla.org' invalid_url = urlparse.urljoin(sumo_host, d_en.get_absolute_url()) self.assertIsNone(from_url(invalid_url)) self.assertEqual(d_en, from_url(invalid_url, check_host=False))
def test_redirect_to_translated_document(self): from_url = Document.from_url d_en = DocumentFactory(locale='en-US', title=u'How to delete Google Chrome?') d_tr = DocumentFactory(locale='tr', title=u'Google Chrome\'u nasıl silerim?', parent=d_en) # The /tr/kb/how-to-delete-google-chrome URL for Turkish locale # should be redirected to /tr/kb/google-chromeu-nasl-silerim # if there is a Turkish translation of the document. tr_translate_url = reverse('wiki.document', locale='tr', args=[d_en.slug]) self.assertEqual(d_en.translated_to('tr'), from_url(tr_translate_url)) self.assertEqual(d_tr, from_url(tr_translate_url)) self.assertEqual(d_en, from_url(d_en.get_absolute_url()))