Views.py error in

Unused variable ‘image_url’

Hi @samyak
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

Hey,

Read the TODO’s carefully and you will find your answer :slight_smile:

i had follow the TODO’s but access token give error -
unexpected indent (, line 211)

LOGCAT -
2020-04-16 11:42:17,537 unitTesting INFO Running pytest
2020-04-16 11:42:26,057 unitTesting INFO ============================= test session starts ==============================
platform linux – Python 3.6.9, pytest-5.3.1, py-1.8.0, pluggy-0.12.0
Django settings: qeats.settings (from ini file)
rootdir: /singhsamyak199-ME_QEATS_REVIEW_MP-4e253f6e-7fd7-11ea-a2cf-4b59fd1a2cc0/singhsamyak199-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 4 items

tests/test_views.py F…s [100%]

=================================== FAILURES ===================================
____________________ TestSocialSharing.test_tag_suggesstion ____________________

self = <tests.test_views.TestSocialSharing object at 0x3e84b8a63a58>

def test_tag_suggesstion(self):
    prefix = os.getenv('USER_SOLUTION')
    if prefix is None:
        prefix = '.'

    image_path = prefix + '/tests/biryani.jpeg'
    if prefix is None:
        prefix = '.'
    img_b64 = restaurants.image_uploader.file_path_to_img64(image_path)

    body = {
            'imgBase64' : img_b64.decode('utf-8')
           }
    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: /singhsamyak199-ME_QEATS_REVIEW_MP-4e253f6e-7fd7-11ea-a2cf-4b59fd1a2cc0/singhsamyak199-ME_QEATS_REVIEW_MP/tests.xml -
    ============== 1 failed, 2 passed, 1 skipped, 1 warning in 6.59s ===============

2020-04-16 11:42:26,060 unitTesting INFO Pytest run complete
2020-04-16 11:42:26,061 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_tag_suggesstion’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_SUCCESS’}

Looks like you have finished QEats , well done , I am closing this ticket

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.