Skip to content

Commit 3b3efed

Browse files
committed
Add tests for _prepare_registration function
Introduces TestPrepareRegistration to verify correct handling of tab_ingest, restrict, and categories attributes in the _prepare_registration function. Ensures registration output matches expected values for various File configurations.
1 parent 3ed43b2 commit 3b3efed

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/unit/test_directupload.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dvuploader.directupload import (
55
_add_files_to_ds,
66
_validate_ticket_response,
7+
_prepare_registration,
78
)
89

910
from dvuploader.file import File
@@ -128,3 +129,50 @@ def test_raises_assertion_error_when_abort_field_missing(self):
128129
}
129130
with pytest.raises(AssertionError):
130131
_validate_ticket_response(response)
132+
133+
134+
class TestPrepareRegistration:
135+
def test_tab_ingest_is_set_correctly(self):
136+
files = [
137+
File(filepath="tests/fixtures/add_dir_files/somefile.txt"),
138+
File(
139+
filepath="tests/fixtures/add_dir_files/somefile.txt",
140+
tab_ingest=False, # type: ignore
141+
),
142+
File(
143+
filepath="tests/fixtures/add_dir_files/somefile.txt",
144+
restrict=True,
145+
),
146+
File(
147+
filepath="tests/fixtures/add_dir_files/somefile.txt",
148+
categories=["Test file"],
149+
),
150+
]
151+
registration = _prepare_registration(files, use_replace=False)
152+
expected_registration = [
153+
{
154+
"categories": ["DATA"],
155+
"mimeType": "application/octet-stream",
156+
"restrict": False,
157+
"tabIngest": True,
158+
},
159+
{
160+
"categories": ["DATA"],
161+
"mimeType": "application/octet-stream",
162+
"restrict": False,
163+
"tabIngest": False,
164+
},
165+
{
166+
"categories": ["DATA"],
167+
"mimeType": "application/octet-stream",
168+
"restrict": True,
169+
"tabIngest": True,
170+
},
171+
{
172+
"categories": ["Test file"],
173+
"mimeType": "application/octet-stream",
174+
"restrict": False,
175+
"tabIngest": True,
176+
},
177+
]
178+
assert registration == expected_registration

0 commit comments

Comments
 (0)