Build Successful but Qeats app not displaying tags

2020-02-02 13:19:32,796 unitTesting INFO Running pytest
2020-02-02 13:19:41,139 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: /aravind-m-9711-ME_QEATS_REVIEW_MP-a1c061e2-45be-11ea-8530-75054be65541/aravind-m-9711-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 4 items

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

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

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

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')

tests/test_views.py:150:


/usr/local/lib/python3.6/dist-packages/django/test/client.py:543: in post
response = super().post(path, data=data, content_type=content_type, secure=secure, **extra)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:357: in post
secure=secure, **extra)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:422: in generic
return self.request(**r)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:503: in request
raise exc_value
/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py:34: in inner
response = get_response(request)
/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py:115: in _get_response
response = self.process_exception_by_middleware(e, request)
/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py:113: in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py:54: in wrapped_view
return view_func(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py:71: in view
return self.dispatch(request, *args, **kwargs)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:495: in dispatch
response = self.handle_exception(exc)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:455: in handle_exception
self.raise_uncaught_exception(exc)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:492: in dispatch
response = handler(request, *args, **kwargs)


self = <restaurants.views.GetTags object at 0x3e422de42f28>
request = <rest_framework.request.Request object at 0x3e422de4f9e8>, args = ()
kwargs = {}, tags = []
body = {‘imgBase64’: ‘/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAigAYkZCTUQwMTAwMGFjMDAzMDAwMGFkMjI…S8h8HMsIZEeGB0GGAohQdEMEAUOopybMmRKHdwQbGXLE5F2oXFibcOkbOZTSHJAVF24Qp73LgNkAqUVOygxT5HrVV9i6RbDtGzhhUuboCA88yhQn/2Q==’}
img_b64 = ‘/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAigAYkZCTUQwMTAwMGFjMDAzMDAwMGFkMjIwMDAwOTM1ZTAwM…US8h8HMsIZEeGB0GGAohQdEMEAUOopybMmRKHdwQbGXLE5F2oXFibcOkbOZTSHJAVF24Qp73LgNkAqUVOygxT5HrVV9i6RbDtGzhhUuboCA88yhQn/2Q==’
image_url = ‘https://i.imgur.com/kE2T5uv.jpg
tag_code = ‘be8bcf78128d4a04a4be60e5c954cd45’

def post(self, request, *args, **kwargs):
    tags = []
    body = request.data
    assert set(['imgBase64']) == set(sorted(list(body.keys())))
    img_b64 = body['imgBase64']
    image_url = restaurants.image_uploader.upload(img_b64)

    # TODO: CRIO_TASK_MODULE_TAG_SUGGESTION
    # Add call to clarifai api here.
    # Refer todo in qeats/restaurants/clarifai_tag_suggestions.py for instructions

    tag_code = get_access_token('CLARIFAI_API_KEY')
  tags = restaurants.clarifai_tag_suggestions.get_tags_suggestions(tag_code,image_url)

E AttributeError: module ‘restaurants’ has no attribute ‘clarifai_tag_suggestions’

restaurants/views.py:208: AttributeError
------------------------------ Captured log call -------------------------------
ERROR django.request:log.py:228 Internal Server Error: /qeats/v1/tags
Traceback (most recent call last):
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py”, line 34, in inner
response = get_response(request)
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py”, line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py”, line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py”, line 71, in view
return self.dispatch(request, *args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 495, in dispatch
response = self.handle_exception(exc)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 455, in handle_exception
self.raise_uncaught_exception(exc)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 492, in dispatch
response = handler(request, *args, **kwargs)
File “/aravind-m-9711-ME_QEATS_REVIEW_MP-a1c061e2-45be-11ea-8530-75054be65541/aravind-m-9711-ME_QEATS_REVIEW_MP/restaurants/views.py”, line 208, in post
tags = restaurants.clarifai_tag_suggestions.get_tags_suggestions(tag_code,image_url)
AttributeError: module ‘restaurants’ has no attribute ‘clarifai_tag_suggestions’
________________ TestSocialSharing.test_post_to_pinterest_share ________________

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

def test_post_to_pinterest_share(self):
    client = Client()
    prefix = os.getenv('USER_SOLUTION')
    if prefix is None:
        prefix = '.'

    image_path = prefix + '/tests/sneakpeak.jpg'
    img_b64 = restaurants.image_uploader.file_path_to_img64(image_path)
    import datetime
    message = 'Great Work!!! Completed module 2 @ {}'.format(str(datetime.datetime.now()))
    request_body = {
                    'imgBase64' : img_b64.decode('utf-8'),
                    'text' : message,
                    'orderId' : '0x12312',
                    'tags' : ['Pinterest', 'Module2'],
                    'share' : ['Pinterest']
                    }
    resp = client.post(r'/qeats/v1/review/share', data=request_body, content_type='application/json')
    resp.status_code == 200
    pinterest_test_util = PinterestTestUtil()
    message_expected = message + ' #Pinterest #Module2'
  assert pinterest_test_util.check_whether_message_is_published(message_expected, image_path)

E AssertionError: assert False
E + where False = <bound method PinterestTestUtil.check_whether_message_is_published of <tests.test_views.PinterestTestUtil object at 0x3e422d795e48>>(‘Great Work!!! Completed module 2 @ 2020-02-02 13:19:40.208460 #Pinterest #Module2’, ‘/aravind-m-9711-ME_QEATS_REVIEW_MP-a1c061e2-45be-11ea-8530-75054be65541/aravind-m-9711-ME_QEATS_REVIEW_MP/tests/sneakpeak.jpg’)
E + where <bound method PinterestTestUtil.check_whether_message_is_published of <tests.test_views.PinterestTestUtil object at 0x3e422d795e48>> = <tests.test_views.PinterestTestUtil object at 0x3e422d795e48>.check_whether_message_is_published

tests/test_views.py:235: AssertionError
----------------------------- Captured stdout call -----------------------------
201 {‘data’: {‘id’: ‘814729388826731132’, ‘url’: ‘https://www.pinterest.com/pin/814729388826731132/’, ‘link’: ‘’, ‘note’: ‘Great Work!!! Completed module 2 @ 2020-02-02 13:19:40.208460 #Pinterest #Module2’}}

Pinterest API: Looks you have hit the per hour API limit

====================================================================================================
=============================== 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: /aravind-m-9711-ME_QEATS_REVIEW_MP-a1c061e2-45be-11ea-8530-75054be65541/aravind-m-9711-ME_QEATS_REVIEW_MP/tests.xml -
    ==================== 2 failed, 2 passed, 1 warning in 6.74s ====================

2020-02-02 13:19:41,143 unitTesting INFO Pytest run complete
2020-02-02 13:19:41,145 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_tag_suggesstion’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’}

You have probably not completed the steps yet, make subsequent changes in views.py and then try to run the server and connect the Android App.

1 Like

I have completed all the TODOs in views.py Still the error persists.
Should I check only the clarifai_tag_suggestions.py and views.py?

check test_views for incomplete imports,if any

@Rahul-Crio.do Thank you.It worked

it’s showing error for me as well, I am getting an error while sending a request to clarifai. Do you know how to resolve this

check if data is in proper format.

use data directly from postman without ‘\n’(curl to python conversion) and convert in int json data using json module

thank u . Now I am getting the outputs in terminal, but I am not getting the tags in the android app

did you make changes in views.py file?
there’s a todo around line 200-220.

did you return a list from the clarifai_tag_suggestions.py file?

outputs contains the list of values

have you resolved this problem

check my answer and see the type of object we get from response.json()

@samar we might have to disqualify you for violating our community guidelines by sharing snippets of your solution code in a public forum. We have clearly asked you not to do this. It is unfair to the hundreds of users taking the mini-project as an assessment step towards qualifying for Crio Launch.

If you can’t follow simple rules, then there is no point in continuing further.

don’t respond with solutions. We will disqualify users who share solutions on the forum.

Sorry, sir. Won’t happen again.

django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I m getting this error while running view.py can you help me out

are you trying to run the views.py file?