Skip to content

Commit

Permalink
tests:database - test IntegrityError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Oct 31, 2023
1 parent 781e9b6 commit 7b5fa46
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from hashlib import sha256
from pathlib import Path
from sqlite3 import IntegrityError
from uuid import uuid4

import pytest
Expand Down Expand Up @@ -123,7 +124,13 @@ def test_insert_select(database_path: Path, test_file: File):
test_file2.uuid = uuid4()

db.files.insert(test_file)

with pytest.raises(IntegrityError):
db.files.insert(test_file2)

test_file2.relative_path = test_file2.relative_path.with_suffix(".new")
db.files.insert(test_file2)

db.commit()

cursor = db.files.select(where="uuid = ?", parameters=[str(test_file.uuid)])
Expand Down

0 comments on commit 7b5fa46

Please sign in to comment.