From 0154113c80d98f7212d8eecded3d2254246814a8 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 30 Apr 2014 15:24:16 +0200 Subject: [PATCH] replace assert with assertEqual --- isso/tests/test_migration.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/isso/tests/test_migration.py b/isso/tests/test_migration.py index ef1af6b..cb4236a 100644 --- a/isso/tests/test_migration.py +++ b/isso/tests/test_migration.py @@ -1,5 +1,10 @@ # -*- encoding: utf-8 -*- +try: + import unittest2 as unittest +except ImportError: + import unittest + import tempfile from os.path import join, dirname @@ -9,16 +14,26 @@ from isso.db import SQLite3 from isso.migrate import Disqus -def test_disqus(): +class TestMigration(unittest.TestCase): - xml = join(dirname(__file__), "disqus.xml") - xxx = tempfile.NamedTemporaryFile() + def test_disqus(self): - db = SQLite3(xxx.name, Config.load(None)) - Disqus(db, xml).migrate() + xml = join(dirname(__file__), "disqus.xml") + xxx = tempfile.NamedTemporaryFile() - assert db.threads["/"]["title"] == "Hello, World!" - assert db.threads["/"]["id"] == 1 + db = SQLite3(xxx.name, Config.load(None)) + Disqus(db, xml).migrate() + + self.assertEqual(db.threads["/"]["title"], "Hello, World!") + self.assertEqual(db.threads["/"]["id"], 1) + + a = db.comments.get(1) + + self.assertEqual(a["author"], "peter") + self.assertEqual(a["email"], "foo@bar.com") + + b = db.comments.get(2) + self.assertEqual(b["parent"] ,a["id"]) a = db.comments.get(1)