quivr/core/tests/test_quivr_file.py
Stan Girard 7acb52a963
feat(quivr-core): beginning (#3388)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-10-21 00:50:31 -07:00

39 lines
898 B
Python

from pathlib import Path
from uuid import uuid4
from quivr_core.files.file import FileExtension, QuivrFile
def test_create_file():
id = uuid4()
brain_id = uuid4()
qfile = QuivrFile(
id=id,
brain_id=brain_id,
original_filename="name",
path=Path("/tmp/name"),
file_extension=FileExtension.txt,
file_sha1="123",
)
assert qfile.id == id
assert qfile.brain_id == brain_id
assert qfile.original_filename == "name"
assert qfile.path == Path("/tmp/name")
def test_create_file_add_metadata():
id = uuid4()
brain_id = uuid4()
qfile = QuivrFile(
id=id,
brain_id=brain_id,
original_filename="name",
path=Path("/tmp/name"),
file_extension=FileExtension.txt,
file_sha1="123",
metadata={"other_id": "id"},
)
assert qfile.metadata["other_id"] == "id"