Now using metadata from setUp method in all tests for wrpylib.mwdb.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 13:01:16 +0000 (13:01 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 13:01:16 +0000 (13:01 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2612 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_mwdb.py

index 5cc2e6343e1820dd5edde09ba917e5a894380feb..e57398b25943058447b433216823c71ff04ad0cc 100644 (file)
@@ -9,11 +9,11 @@ import wrpylib.mwdb
 class TestMwDb(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
 class TestMwDb(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
-        cls.metadata = sqlalchemy.MetaData()
         cls.engine = create_engine('mysql://philipp@localhost:3306/philipp_winterrodeln_wiki?charset=utf8&use_unicode=1')
         cls.Session = sessionmaker(bind=cls.engine)
 
     def setUp(self):
         cls.engine = create_engine('mysql://philipp@localhost:3306/philipp_winterrodeln_wiki?charset=utf8&use_unicode=1')
         cls.Session = sessionmaker(bind=cls.engine)
 
     def setUp(self):
+        self.metadata = sqlalchemy.MetaData()
         self.session = self.Session()
 
     def tearDown(self):
         self.session = self.Session()
 
     def tearDown(self):
@@ -25,25 +25,21 @@ class TestMwDb(unittest.TestCase):
         self.assertEqual(page.page_id, 1321)
 
     def test_revision_table(self):
         self.assertEqual(page.page_id, 1321)
 
     def test_revision_table(self):
-        metadata = sqlalchemy.MetaData()
-        RevisionTable = wrpylib.mwdb.revision_table(metadata)
+        RevisionTable = wrpylib.mwdb.revision_table(self.metadata)
         revision_table = self.session.query(RevisionTable).filter(RevisionTable.c.rev_id == 666).first()
         self.assertEqual(revision_table.rev_id, 666)
 
     def test_text_table(self):
         revision_table = self.session.query(RevisionTable).filter(RevisionTable.c.rev_id == 666).first()
         self.assertEqual(revision_table.rev_id, 666)
 
     def test_text_table(self):
-        metadata = sqlalchemy.MetaData()
-        TextTable = wrpylib.mwdb.text_table(metadata)
+        TextTable = wrpylib.mwdb.text_table(self.metadata)
         text_table = self.session.query(TextTable).filter(TextTable.c.old_id == 51).first()
         self.assertEqual(text_table.old_id, 51)
 
     def test_user_table(self):
         text_table = self.session.query(TextTable).filter(TextTable.c.old_id == 51).first()
         self.assertEqual(text_table.old_id, 51)
 
     def test_user_table(self):
-        metadata = sqlalchemy.MetaData()
-        UserTable = wrpylib.mwdb.user_table(metadata)
+        UserTable = wrpylib.mwdb.user_table(self.metadata)
         user_table = self.session.query(UserTable).filter(UserTable.c.user_id == 5).first()
         self.assertEqual(user_table.user_id, 5)
 
     def test_categorylinks_table(self):
         user_table = self.session.query(UserTable).filter(UserTable.c.user_id == 5).first()
         self.assertEqual(user_table.user_id, 5)
 
     def test_categorylinks_table(self):
-        metadata = sqlalchemy.MetaData()
-        CategorylinksTable = wrpylib.mwdb.categorylinks_table(metadata)
+        CategorylinksTable = wrpylib.mwdb.categorylinks_table(self.metadata)
         categorylinks_table = self.session.query(CategorylinksTable).filter(CategorylinksTable.c.cl_from == 229).first()
         self.assertEqual(categorylinks_table.cl_from, 229)
         categorylinks_table = self.session.query(CategorylinksTable).filter(CategorylinksTable.c.cl_from == 229).first()
         self.assertEqual(categorylinks_table.cl_from, 229)