Chemical-Curation / chemcurator_django

Backend services for chemical curation
https://api.chemreg.epa.gov
MIT License
1 stars 0 forks source link

External ID uniqueness #198

Closed cmgrulke closed 3 years ago

cmgrulke commented 3 years ago

As a researcher I want external ids to be unique within a list So that they can actually be guaranteed to be clear identifiers back to an external source

Acceptance Criteria:

Test:

mwfrost commented 3 years ago

Proposed test requests

With the fixtures loaded, there will be a Record object with external_id of 47 and list id of 2.

This POST will attempt to create another Record with those same values:

{
"data": {
        "type": "record",
        "attributes": {
            "external_id": "47",
            "score": 4.7,
            "message": "I made a record",
            "is_validated": false
        },
        "relationships": {
            "list": {
                "data": {
                "id": 2,
                "type": "list"
                }
            },
            "substance": {
                "data": {
                "id": 2,
                "type": "substance"
                }
            }
        }
    }
}

When it fails, change the external_id and try again. It will succeed. Then change the id for the "list" relationship to "1" and it should succeed again.