Fixed db wrapper unit tests, fixed a db facade bug.

This commit is contained in:
s3lph 2018-08-31 21:01:02 +02:00
parent c26e0ffc21
commit 56ce2a73cb
2 changed files with 8 additions and 8 deletions

View file

@ -285,9 +285,9 @@ class MatematDatabase(object):
}) })
# TODO: Implement reason field # TODO: Implement reason field
c.execute(''' c.execute('''
INSERT INTO modifications (ta_id, agent_id, reason) INSERT INTO modifications (ta_id, agent, reason)
VALUES (last_insert_rowid(), :agent_id, NULL) VALUES (last_insert_rowid(), :agent, NULL)
''', {'agent_id': agent.id}) ''', {'agent': agent.name})
c.execute(''' c.execute('''
UPDATE users SET UPDATE users SET
username = :username, username = :username,

View file

@ -53,12 +53,12 @@ class DatabaseTest(unittest.TestCase):
with self.db as db: with self.db as db:
with db.transaction() as c: with db.transaction() as c:
c.execute(''' c.execute('''
INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42) INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42, 0)
''') ''')
c = db._sqlite_db.cursor() c = db._sqlite_db.cursor()
c.execute("SELECT * FROM users") c.execute("SELECT * FROM users")
user = c.fetchone() user = c.fetchone()
self.assertEqual((1, 'testuser', None, 'supersecurepassword', None, 1, 1, 0, 42), user) self.assertEqual((1, 'testuser', None, 'supersecurepassword', None, 1, 1, 0, 42, 0), user)
def test_transaction_rollback(self) -> None: def test_transaction_rollback(self) -> None:
""" """
@ -67,9 +67,9 @@ class DatabaseTest(unittest.TestCase):
with self.db as db: with self.db as db:
try: try:
with db.transaction() as c: with db.transaction() as c:
c.execute(""" c.execute('''
INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42) INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42, 0)
""") ''')
raise ValueError('This should trigger a rollback') raise ValueError('This should trigger a rollback')
except ValueError as e: except ValueError as e:
if str(e) != 'This should trigger a rollback': if str(e) != 'This should trigger a rollback':