Unit Test raising an validation error that souldn't be raised #8317
Unanswered
trolliama
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am creating this API and in determined point of my tests (contract creation endpoint) I am receiving an invalid error.
The error says that I am not passing some required attribute to the API when creating a contract, but I am. The weirdest thing is that when I tried to create from the Web browser by hand, the issue wasn't raised and the contract was created
I am puting here a lot of codes just for replication purposes, but the code that is really important to see it is the
ContractSerializer
and thetest_contract_creation
functionHere is my code:
models.py
view.py
serializers.py
test_contract_endpoint.py
Now this is the validation error I am receiving:
{'cargo_set': [ErrorDetail(string='This field is required.', code='required')]}
Here is a print of the contract that I created by hand in web browser and the payload passed to it was the same from the unit test:

After some research in the source code I noticed that my
cargo_set
are being instatiated as aListSerializer
and the problem is when thefield.get_value()
is called inside the.to_internal_data()
. I actually don't know why, but the regex inside theparse_html_list()
isn't being matched. This was the only thing that I noticed that could be the problemI would be glad for any help. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions