forked from s3lph/matemat
Fixed db wrapper unit tests, fixed a db facade bug.
This commit is contained in:
parent
c26e0ffc21
commit
56ce2a73cb
2 changed files with 8 additions and 8 deletions
|
@ -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,
|
||||
|
|
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue