-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import json | ||
|
||
test_json = './tests/fixtures/test_data_types.json' | ||
|
||
def test_create_or_update_data_type(client): | ||
new_data_type = { | ||
"new_data_type": { | ||
"MASS SPECTRUM": "MS" | ||
} | ||
} | ||
|
||
response = client.post('/spectra_type_api/data_type', json=new_data_type) | ||
assert response.status_code == 200 | ||
|
||
response_data = response.json() | ||
assert response_data.get("datatypes") is not None | ||
assert response_data["datatypes"].get("MASS SPECTRUM") == "MS" | ||
|
||
def test_create_or_update_data_type_unchanged(client): | ||
# data type already exists in JSON | ||
new_data_type = { | ||
"new_data_type": { | ||
"INFRARED SPECTRUM": "INFRARED" | ||
} | ||
} | ||
|
||
response = client.post('/spectra_type_api/data_type', json=new_data_type) | ||
assert response.status_code == 400 | ||
|
||
response_data = response.json() | ||
|
||
assert "message" in response_data | ||
assert response_data["message"] == "Data type 'INFRARED SPECTRUM' already exists" | ||
|
||
def test_create_or_update_data_type_file_not_found(client): | ||
original_test_json = test_json | ||
test_json = './tests/fixtures/non_existent_test_data.json' | ||
|
||
new_data_type = { | ||
"new_data_type": { | ||
"RAMAN SPECTRUM": "RAMAN" | ||
} | ||
} | ||
|
||
response = client.post('/spectra_type_api/data_type', json=new_data_type) | ||
assert response.status_code == 200 | ||
response_data = response.json() | ||
assert len(response_data.get("datatypes")) == 1 | ||
assert response_data["datatypes"].get("RAMAN SPECTRUM") == "RAMAN" | ||
|
||
test_json = original_test_json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"datatypes": { | ||
"NMRSPECTRUM": "NMR", | ||
"INFRARED SPECTRUM": "INFRARED" | ||
} | ||
} |