Merged test_sqlalchemy.py with test_mwdb.py.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 13:01:20 +0000 (13:01 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 29 Jan 2017 13:01:20 +0000 (13:01 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2614 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_mwdb.py
tests/test_sqlalchemy.py [deleted file]

index cce9f2d10bddc76437d7a2e40855b9071ddf5d13..94d40b12a4218d929b1cf60f4039c7b7cbc371fc 100644 (file)
@@ -23,23 +23,41 @@ class TestMwDb(unittest.TestCase):
         Page = wrpylib.mwdb.page_table(self.metadata)
         page = self.session.query(Page).filter(Page.c.page_id==1321).first()
         self.assertEqual(page.page_id, 1321)
+        self.assertEqual(type(page.page_title), str)
+        self.assertEqual(type(page.page_restrictions), bytes)
+        self.assertEqual(type(page.page_touched), str)
 
     def test_revision_table(self):
         Revision = wrpylib.mwdb.revision_table(self.metadata)
         revision = self.session.query(Revision).filter(Revision.c.rev_id == 666).first()
         self.assertEqual(revision.rev_id, 666)
+        self.assertEqual(type(revision.rev_comment), str)
+        self.assertEqual(type(revision.rev_user_text), str)
+        self.assertEqual(type(revision.rev_timestamp), str)
 
     def test_text_table(self):
         Text = wrpylib.mwdb.text_table(self.metadata)
         text = self.session.query(Text).filter(Text.c.old_id == 51).first()
         self.assertEqual(text.old_id, 51)
+        self.assertEqual(type(text.old_text), str)
+        self.assertEqual(type(text.old_flags), str)
+        self.assertEqual(text.old_flags, 'utf-8')
+
 
     def test_user_table(self):
         User = wrpylib.mwdb.user_table(self.metadata)
-        user = self.session.query(User).filter(User.c.user_id == 5).first()
-        self.assertEqual(user.user_id, 5)
+        user = self.session.query(User).filter(User.c.user_id == 1).first()
+        self.assertEqual(user.user_id, 1)
+        self.assertEqual(type(user.user_name), str)
+        self.assertEqual(type(user.user_real_name), str)
+        self.assertEqual(type(user.user_email), str)
+        self.assertEqual(user.user_name, 'Philipp')
+
 
     def test_categorylinks_table(self):
         Categorylinks = wrpylib.mwdb.categorylinks_table(self.metadata)
-        categorylinks = self.session.query(Categorylinks).filter(Categorylinks.c.cl_from == 229).first()
-        self.assertEqual(categorylinks.cl_from, 229)
+        categorylinks = self.session.query(Categorylinks).filter(Categorylinks.c.cl_from == 609).first()
+        self.assertEqual(categorylinks.cl_from, 609)
+        self.assertEqual(type(categorylinks.cl_to), str)
+        self.assertEqual(type(categorylinks.cl_sortkey), str)
+        self.assertEqual(categorylinks.cl_sortkey, 'ALT BÄRNBAD')
diff --git a/tests/test_sqlalchemy.py b/tests/test_sqlalchemy.py
deleted file mode 100644 (file)
index f0f8664..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python3.4
-from sqlalchemy import schema
-from sqlalchemy.engine import create_engine
-from sqlalchemy.sql import select
-from wrpylib import mwdb
-import unittest
-
-
-def connect():
-    engine = create_engine('mysql://philipp@localhost:3306/philipp_winterrodeln_wiki?charset=utf8&use_unicode=1')
-    connection = engine.connect()
-    connection.begin()
-    return connection
-
-
-class TestSqlAlchemy(unittest.TestCase):
-    def test_datatype_page(self):
-        metadata = schema.MetaData()
-        tpage = mwdb.page_table(metadata)
-        page = connect().execute(select([tpage], tpage.c.page_id == 1321)).first()
-        assert type(page.page_title) == str
-        assert type(page.page_restrictions) == bytes
-        assert type(page.page_touched) == str
-
-    def test_datatype_revision(self):
-        metadata = schema.MetaData()
-        trevision = mwdb.revision_table(metadata)
-        revision = connect().execute(select([trevision], trevision.c.rev_id == 7586)).first()
-        assert type(revision.rev_comment) == str
-        assert type(revision.rev_user_text) == str
-        assert type(revision.rev_timestamp) == str
-
-    def test_datatypes_text(self):
-        metadata = schema.MetaData()
-        ttext = mwdb.text_table(metadata)
-        text = connect().execute(select([ttext], ttext.c.old_id==7438)).first()
-        assert type(text.old_text) == str
-        assert type(text.old_flags) == str
-        assert text.old_flags == 'utf-8'
-
-    def test_datatype_user(self):
-        metadata = schema.MetaData()
-        tuser = mwdb.user_table(metadata)
-        user = connect().execute(select([tuser], tuser.c.user_id == 1)).first()
-        assert type(user.user_name) == str
-        assert type(user.user_real_name) == str
-        assert type(user.user_email) == str
-        assert user.user_name == 'Philipp'
-
-    def test_datatype_categorylinks(self):
-        metadata = schema.MetaData()
-        tcategorylinks = mwdb.categorylinks_table(metadata)
-        categorylinks = connect().execute(select([tcategorylinks], tcategorylinks.c.cl_from == 609)).first()
-        assert type(categorylinks.cl_to) == str
-        assert type(categorylinks.cl_sortkey) == str
-        assert categorylinks.cl_sortkey == 'ALT BÄRNBAD'