Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/opengeodeweb_microservice/database/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class Data(Base):
id: Mapped[str] = mapped_column(
String, primary_key=True, default=lambda: str(uuid.uuid4()).replace("-", "")
)
native_file_name: Mapped[str] = mapped_column(String, nullable=False)
viewable_file_name: Mapped[str] = mapped_column(String, nullable=False)
geode_object: Mapped[str] = mapped_column(String, nullable=False)
viewer_object: Mapped[str] = mapped_column(String, nullable=False)

native_file_name: Mapped[str | None] = mapped_column(String, nullable=True)
viewable_file_name: Mapped[str | None] = mapped_column(String, nullable=True)

light_viewable: Mapped[str | None] = mapped_column(String, nullable=True)
input_file: Mapped[str | None] = mapped_column(String, nullable=True)
Expand All @@ -22,19 +24,15 @@ class Data(Base):
@staticmethod
def create(
geode_object: str,
viewer_object: str,
input_file: str | None = None,
additional_files: list[str] | None = None,
) -> "Data":
input_file = input_file or ""
additional_files = additional_files or []

data_entry = Data(
geode_object=geode_object,
viewer_object=viewer_object,
input_file=input_file,
additional_files=additional_files,
native_file_name="",
viewable_file_name="",
light_viewable=None,
)

session = get_session()
Expand Down
9 changes: 7 additions & 2 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

def test_data_crud_operations(clean_database):
data = Data.create(
geode_object="test_object", input_file="test.txt", additional_files=[]
geode_object="test_object",
viewer_object="test_viewer",
input_file="test.txt",
additional_files=[],
)
print("id", data.id, flush=True)
assert data.id is not None
Expand All @@ -21,7 +24,9 @@ def test_data_crud_operations(clean_database):

def test_data_with_additional_files(clean_database):
files = ["file1.txt", "file2.txt"]
data = Data.create(geode_object="test_files", additional_files=files)
data = Data.create(
geode_object="test_files", viewer_object="test_viewer", additional_files=files
)
assert data.id is not None
assert isinstance(data.id, str)

Expand Down