Assertion error in module 3 , 1 test case fail

  1. Describe the issue briefly

getting assertion error

client = Client()

    resp = client.post(r'/qeats/v1/tags', data=json.dumps(body), content_type='application/json')
    assert resp.status_code == 200
    actual_tag_suggesstion_received = json.loads(resp.content)
    expected_tag_suggestion = ['rice', 'meat', 'vegetable', 'paella', 'chicken', 'pilaf', 'pepper', 'saffron', 'pork', 'fried rice', 'curry', 'shrimp', 'risotto', 'seafood', 'sauce', 'onion', 'chili', 'chicken curry', 'prawn', 'cereal']

    print(actual_tag_suggesstion_received)
    assert type(actual_tag_suggesstion_received) == type([])
  assert expected_tag_suggestion[0:3] == actual_tag_suggesstion_received[0:3]

E AssertionError: assert [‘rice’, ‘meat’, ‘vegetable’] == []
E Left contains 3 more items, first extra item: ‘rice’
E Use -v to get the full diff
tests/test_views.py:157: AssertionError
----------------------------- Captured stdout call -----------------------------
[]
=============================== warnings summary ===============================
/usr/local/lib/python3.6/dist-packages/_pytest/junitxml.py:436
/usr/local/lib/python3.6/dist-packages/_pytest/junitxml.py:436: PytestDeprecationWarning: The ‘junit_family’ default value will change to ‘xunit2’ in pytest 6.0.
Add ‘junit_family=legacy’ to your pytest.ini file to silence this warning and make your suite compatible.
_issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

– Docs: https://docs.pytest.org/en/latest/warnings.html

  • generated xml file: /anshima03-ME_QEATS_REVIEW_MP-062c1e3e-855f-11ea-bc8c-b531bd024d55/anshima03-ME_QEATS_REVIEW_MP/tests.xml -
    ============== 1 failed, 2 passed, 1 skipped, 1 warning in 7.70s ===============
  1. How much time have you spent debugging this issue?
    (Please spend at least 15 minutes to resolve the issue on your own before posting a new topic here)
    1 hour

  2. What is your hypothesis?

Hi @anshima03
Looks like you are facing challenges in the current module.

Below is a link to all the FAQ’s for the current module

Below are a few similar topics raised by other users which you might find usefull

Note - This is a BETA Feature,if you find this helpful, kindly let us know.
Feedback link - https://forms.gle/cmxN5pdTXgnwgC986

Kindly mark this as a solution if this has helped you solve your query

Your list of tags might be empty. Make sure that your list contains those tags or not. print the list and check the tags. Let me know if it helped you or not.

what should I return if response is 400 ?
i returned an empty list if my response is 400
when my response is 200 it is printing list and is working fine .
also when I’m printing list when response is 400 this error generates “list out of range error is coming”

You shouldn’t get response 400 at any cost. It means that it is a bad request. If you get response in 5xx series then it might be an issue with the server. But if you get 4xx series response then it is an issue from the client side.

sir the test case fails because it says list out of index,which is possible for response 400 because I’m returning a list.

Then please make sure your API call is correct. Use correct format.
There are 2 parameters header and data.
Header contains ‘Authorization’, ‘Content-Type’.
Data contains the body.

Please visit this page and observe the curl command carefully.
https://docs.clarifai.com/api-guide/predict/images
The below website would also be helpful.
https://curl.trillworks.com/

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.