Skip to content

Commit 3b515a2

Browse files
committed
Revert factory, tried to include -upload attribute in hopes that'd fix tests, it didn't
1 parent 138b580 commit 3b515a2

1 file changed

Lines changed: 0 additions & 32 deletions

File tree

hypha/apply/stream_forms/testing/factories.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import random
32
import uuid
43
from collections import defaultdict
54

@@ -75,18 +74,6 @@ def _create(cls, *args, form_fields=None, for_factory=None, clean=False, **kwarg
7574
or for_factory.Meta.model.form_fields.field.to_python(form_fields)
7675
}
7776

78-
# Get UUIDs of the file fields to add "-uploads" fields later
79-
file_fields = []
80-
file_types = ("image", "file", "multi_file")
81-
for field in form_fields:
82-
try:
83-
if field["type"] in file_types:
84-
file_fields.append(field["id"])
85-
except TypeError:
86-
if field.block_type in file_types:
87-
file_fields.append(field.id)
88-
# field["id"] for field in form_fields if field["type"] in ("file", "multi_file")]
89-
9077
form_data = {}
9178
for name, answer in kwargs.items():
9279
try:
@@ -106,25 +93,6 @@ def _create(cls, *args, form_fields=None, for_factory=None, clean=False, **kwarg
10693
clean_object.delete()
10794
return form_data
10895

109-
for id in file_fields:
110-
uploads = []
111-
if entry := form_data.get(id):
112-
if not isinstance(entry, list):
113-
entry = [entry]
114-
115-
for file in entry:
116-
uploads.append(
117-
{
118-
"id": str(uuid.uuid4()),
119-
"name": file._name,
120-
"size": random.randint(20, 100000),
121-
"type": "tus",
122-
"url": "",
123-
}
124-
)
125-
126-
form_data[f"{id}-uploads"] = json.dumps(uploads)
127-
12896
return form_data
12997

13098
@classmethod

0 commit comments

Comments
 (0)