1
0
Fork 0
forked from s3lph/matemat

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
c.execute('''
INSERT INTO modifications (ta_id, agent_id, reason)
VALUES (last_insert_rowid(), :agent_id, NULL)
''', {'agent_id': agent.id})
INSERT INTO modifications (ta_id, agent, reason)
VALUES (last_insert_rowid(), :agent, NULL)
''', {'agent': agent.name})
c.execute('''
UPDATE users SET
username = :username,

View file

@ -53,12 +53,12 @@ class DatabaseTest(unittest.TestCase):
with self.db as db:
with db.transaction() as c:
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.execute("SELECT * FROM users")
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:
"""
@ -67,9 +67,9 @@ class DatabaseTest(unittest.TestCase):
with self.db as db:
try:
with db.transaction() as c:
c.execute("""
INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42)
""")
c.execute('''
INSERT INTO users VALUES (1, 'testuser', NULL, 'supersecurepassword', NULL, 1, 1, 0, 42, 0)
''')
raise ValueError('This should trigger a rollback')
except ValueError as e:
if str(e) != 'This should trigger a rollback':