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
54 changes: 54 additions & 0 deletions specifyweb/backend/workbench/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,57 @@ def test_create_record_set(self) -> None:

rs = Recordset.objects.get(id=recordset_id)
self.assertEqual(rs.recordsetitems.count(), 3)

# [WorkBench] Preserve imported data and mapping after reopening a dataset
def test_preserve_imported_data_and_mapping(self) -> None:
client = Client()
client.force_login(self.specifyuser)

columns = ["Catalog Number", "Remarks"]
rows = [["123", "First row"], ["456", "Second row"]]
uploadplan = {
"baseTableName": "collectionobject",
"uploadable": {
"uploadTable": {
"wbcols": {
"catalognumber": "Catalog Number",
"remarks": "Remarks",
},
"static": {},
"toOne": {},
"toMany": {},
}
},
}

response = client.post(
"/api/workbench/dataset/",
data={
"name": "Imported dataset",
"columns": columns,
"rows": rows,
"importedfilename": "records.csv",
},
content_type="application/json",
)
self.assertEqual(response.status_code, 201)
datasetid = json.loads(response.content)["id"]

response = client.put(
f"/api/workbench/dataset/{datasetid}/",
data={"uploadplan": uploadplan},
content_type="application/json",
)
self.assertEqual(response.status_code, 204)

response = client.get(f"/api/workbench/dataset/{datasetid}/")
self.assertEqual(response.status_code, 200)
dataset = json.loads(response.content)

self.assertEqual(dataset["columns"], columns)
self.assertEqual(
dataset["rows"],
[row + [""] for row in rows],
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
self.assertEqual(dataset["uploadplan"], uploadplan)

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const errorBody = (
</Link.NewTab>
),
discourseLink: (label): JSX.Element => (
<Link.NewTab href="https://speciforum.org/">
{label}
</Link.NewTab>
<Link.NewTab href="https://speciforum.org/">{label}</Link.NewTab>
),
}}
string={mainText.errorResolutionSecondDescription()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ export const resources: RA<ResourceConfig> = [
resourceName: 'institution',
label: setupToolText.institution(),
description: setupToolText.institutionDescription(),
documentationUrl:
'https://speciforum.org/t/guided-setup/3234',
documentationUrl: 'https://speciforum.org/t/guided-setup/3234',
fields: [
{
name: 'name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ const baseWbVariant = {
doSuccessful: wbText.uploadSuccessful(),
},
},
documentationUrl:
'https://speciforum.org/t/the-specify-7-workbench/540',
documentationUrl: 'https://speciforum.org/t/the-specify-7-workbench/540',
} as const;

// Defines a shared interface to access dataset variants
Expand Down Expand Up @@ -145,8 +144,7 @@ export const datasetVariants = {
route: (id: number) => `/specify/attachments/import/${id}`,
// Actually, in retrorespect, this would be a nice feature
metaRoute: f.never,
documentationUrl:
'https://speciforum.org/t/batch-attachment-uploader/1374',
documentationUrl: 'https://speciforum.org/t/batch-attachment-uploader/1374',
},
} as const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const doFetch = async (url: string): Promise<IR<unknown>> =>
headers: { Authorization: getToken() },
}).then(async (response) => response.json());


const fetchComponents = async (
url = componentsApiUrl
): Promise<RA<IR<unknown>>> =>
Expand Down
Loading