Skip to content

Commit

Permalink
tests.database - test all_files view
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Nov 6, 2024
1 parent 0bd7adb commit 3e393df
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
Expand Up @@ -12,6 +12,7 @@
from acacore.database.files_db import EventPath
from acacore.database.files_db import SignatureCount
from acacore.models.event import Event
from acacore.models.file import BaseFile
from acacore.models.file import ConvertedFile
from acacore.models.file import MasterFile
from acacore.models.file import OriginalFile
Expand Down Expand Up @@ -58,13 +59,15 @@ def test_database_tables(database_file: Path):
assert db.statutory_files.name in tables
assert db.log.name in tables
assert db.metadata.name in tables
assert db.all_files.name in views
assert db.log_paths.name in views
assert db.identification_warnings.name in views
assert db.signatures_count.name in views
assert db.actions_count.name in views
assert db.checksums_count.name in views


# noinspection DuplicatedCode
def test_database_insert_select(database_file: Path):
with FilesDB(database_file) as db:
db.init()
Expand All @@ -84,6 +87,9 @@ def test_database_insert_select(database_file: Path):
assert len(db.master_files) == 1
assert len(db.access_files) == 1
assert len(db.statutory_files) == 1
assert len(db.all_files) == (
len(db.original_files) + len(db.master_files) + len(db.access_files) + len(db.statutory_files)
)
assert len(db.log) == 1
assert len(db.log_paths) == 1
assert len(db.identification_warnings) == 2
Expand All @@ -102,6 +108,7 @@ def test_database_insert_select(database_file: Path):
assert isinstance(db.master_files.select().fetchone(), MasterFile)
assert isinstance(db.access_files.select().fetchone(), ConvertedFile)
assert isinstance(db.statutory_files.select().fetchone(), ConvertedFile)
assert isinstance(db.all_files.select().fetchone(), BaseFile)
assert isinstance(db.log.select().fetchone(), Event)

assert isinstance(db.log_paths.select().fetchone(), EventPath)
Expand Down

0 comments on commit 3e393df

Please sign in to comment.