From fa50632a9d87c3989566fed3e49c160a132e0d14 Mon Sep 17 00:00:00 2001 From: Agustin Henze Date: Sun, 9 Mar 2014 03:14:40 +0100 Subject: Imported Upstream version 6.4.0 --- tests/test_command_import_wordpress.py | 83 ++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) (limited to 'tests/test_command_import_wordpress.py') diff --git a/tests/test_command_import_wordpress.py b/tests/test_command_import_wordpress.py index d12c7f6..04e0631 100644 --- a/tests/test_command_import_wordpress.py +++ b/tests/test_command_import_wordpress.py @@ -51,6 +51,79 @@ Easy. self.assertEqual(expected_xml, self.import_command._glue_xml_lines(xml)) +class TestQTranslateContentSeparation(BasicCommandImportWordpress): + + def test_conserves_qtranslate_less_post(self): + content = """Si vous préférez savoir à qui vous parlez commencez par visiter l'À propos. + +Quoiqu'il en soit, commentaires, questions et suggestions sont les bienvenues !""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual(1, len(content_translations)) + self.assertEqual(content, content_translations[""]) + + def test_split_a_two_language_post(self): + content = """Si vous préférez savoir à qui vous parlez commencez par visiter l'À propos. + +Quoiqu'il en soit, commentaires, questions et suggestions sont les bienvenues ! +If you'd like to know who you're talking to, please visit the about page. + +Comments, questions and suggestions are welcome ! +""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual("""Si vous préférez savoir à qui vous parlez commencez par visiter l'À propos. + +Quoiqu'il en soit, commentaires, questions et suggestions sont les bienvenues ! +""", content_translations["fr"]) + self.assertEqual("""If you'd like to know who you're talking to, please visit the about page. + +Comments, questions and suggestions are welcome ! +""", content_translations["en"]) + + def test_split_a_two_language_post_with_teaser(self): + content = """Si vous préférez savoir à qui vous parlez commencez par visiter l'À propos. + +Quoiqu'il en soit, commentaires, questions et suggestions sont les bienvenues ! +If you'd like to know who you're talking to, please visit the about page. + +Comments, questions and suggestions are welcome ! + +Plus de détails ici ! + +More details here ! +""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual("""Si vous préférez savoir à qui vous parlez commencez par visiter l'À propos. + +Quoiqu'il en soit, commentaires, questions et suggestions sont les bienvenues ! + \n\ +Plus de détails ici ! +""", content_translations["fr"]) + self.assertEqual("""If you'd like to know who you're talking to, please visit the about page. + +Comments, questions and suggestions are welcome ! + \n\ +More details here ! +""", content_translations["en"]) + + def test_split_a_two_language_post_with_intermission(self): + content = """Voila voilaCOMMONBLA""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual("Voila voila COMMON", content_translations["fr"]) + self.assertEqual("COMMON BLA", content_translations["en"]) + + def test_split_a_two_language_post_with_uneven_repartition(self): + content = """Voila voilaCOMMONMOUFBLA""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual("Voila voila COMMON MOUF", content_translations["fr"]) + self.assertEqual("COMMON BLA", content_translations["en"]) + + def test_split_a_two_language_post_with_uneven_repartition_bis(self): + content = """Voila voilaBLACOMMONMOUF""" + content_translations = self.module.separate_qtranslate_content(content) + self.assertEqual("Voila voila COMMON MOUF", content_translations["fr"]) + self.assertEqual("BLA COMMON", content_translations["en"]) + + class CommandImportWordpressRunTest(BasicCommandImportWordpress): def setUp(self): super(self.__class__, self).setUp() @@ -134,7 +207,7 @@ class CommandImportWordpressTest(BasicCommandImportWordpress): self.assertEqual('Wordpress blog title', context['BLOG_TITLE']) self.assertEqual('Nikola test blog ;) - with moré Ümläüts', context['BLOG_DESCRIPTION']) - self.assertEqual('http://some.blog', context['SITE_URL']) + self.assertEqual('http://some.blog/', context['SITE_URL']) self.assertEqual('mail@some.blog', context['BLOG_EMAIL']) self.assertEqual('Niko', context['BLOG_AUTHOR']) @@ -173,7 +246,7 @@ class CommandImportWordpressTest(BasicCommandImportWordpress): 'kontakt', '2009-07-16 20:20:32', None, []) self.assertTrue(write_content.called) - write_content.assert_any_call('new_site/posts/200704hoert.wp'.replace('/', os.sep), + write_content.assert_any_call('new_site/posts/2007/04/hoert.wp'.replace('/', os.sep), """An image. caption test @@ -193,7 +266,7 @@ The end. """) write_content.assert_any_call( - 'new_site/posts/200807arzt-und-pfusch-s-i-c-k.wp'.replace('/', os.sep), + 'new_site/posts/2008/07/arzt-und-pfusch-s-i-c-k.wp'.replace('/', os.sep), '''Arzt+Pfusch - S.I.C.K.Arzt+Pfusch - S.I.C.K.Gerade bin ich \xfcber das Album S.I.C.K von Arzt+Pfusch gestolpert, welches Arzt+Pfusch zum Download f\xfcr lau anbieten. Das Album steht unter einer Creative Commons BY-NC-ND-Lizenz. Die Ladung noisebmstupidevildustrial gibts als MP3s mit 64kbps und VBR, als Ogg Vorbis und als FLAC (letztere hier). Artwork und Lyrics gibts nochmal einzeln zum Download.''') write_content.assert_any_call( @@ -214,11 +287,11 @@ Diese Daten sind f\xfcr mich nicht bestimmten Personen zuordenbar. Eine Zusammen self.assertEqual( self.import_command.url_map['http://some.blog/2007/04/hoert/'], - 'http://some.blog/posts/200704hoert.html') + 'http://some.blog/posts/2007/04/hoert.html') self.assertEqual( self.import_command.url_map[ 'http://some.blog/2008/07/arzt-und-pfusch-s-i-c-k/'], - 'http://some.blog/posts/200807arzt-und-pfusch-s-i-c-k.html') + 'http://some.blog/posts/2008/07/arzt-und-pfusch-s-i-c-k.html') self.assertEqual( self.import_command.url_map['http://some.blog/kontakt/'], 'http://some.blog/stories/kontakt.html') -- cgit v1.2.3