Module 3 unit test failed

tests.test_views.TestSocialSharing - test_post_to_pinterest_share failed.

Executing successfully with Postman and QEats app.

Trying to resolve since morning.

Definitely not API limit exceeded error as I tried after 2-3 hours of making last API request.

What is your error?
Are you able to post using the script?

Hey. Just looked at your Unit Testing log file.

Seems like you’ve hit the Pinterest API rate limit.

Do refer here Pinterest assessment fails due to hitting the API rate limit to solve the same. :slight_smile:

Yes I am able to post using script.

I am attaching the unit test log file

2020-01-26 13:44:05,918 unitTesting  INFO     Running pytest
2020-01-26 13:44:14,643 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: /sshardul007-ME_QEATS_REVIEW_MP-e7beb914-4041-11ea-a0fe-b37878374dad/sshardul007-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 3 items

tests/ ..F                                                  [100%]

=================================== FAILURES ===================================
________________ TestSocialSharing.test_post_to_pinterest_share ________________

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

    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(
        request_body = {
                        'imgBase64' : img_b64.decode('utf-8'),
                        'text' : message,
                        'orderId' : '0x12312',
                        'tags' : ['Pinterest', 'Module2'],
                        'share' : ['Pinterest']
        resp ='/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 0x3e1e350be278>>('Great Work!!! Completed module 2 @ 2020-01-26 13:44:13.331473 #Pinterest #Module2', '/sshardul007-ME_QEATS_REVIEW_MP-e7beb914-4041-11ea-a0fe-b37878374dad/sshardul007-ME_QEATS_REVIEW_MP/tests/sneakpeak.jpg')
E        +    where <bound method PinterestTestUtil.check_whether_message_is_published of <tests.test_views.PinterestTestUtil object at 0x3e1e350be278>> = <tests.test_views.PinterestTestUtil object at 0x3e1e350be278>.check_whether_message_is_published

tests/ AssertionError
----------------------------- Captured stdout call -----------------------------

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

=============================== warnings summary ===============================
  /usr/local/lib/python3.6/dist-packages/_pytest/ 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:
- generated xml file: /sshardul007-ME_QEATS_REVIEW_MP-e7beb914-4041-11ea-a0fe-b37878374dad/sshardul007-ME_QEATS_REVIEW_MP/tests.xml -
==================== 1 failed, 2 passed, 1 warning in 7.36s ====================

2020-01-26 13:44:14,838 unitTesting  INFO     Pytest run complete
2020-01-26 13:44:14,858 unitTesting  INFO     Report generated: {'tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli': 'TEST_STATUS_SUCCESS', 'tests.test_views.TestSocialSharing.test_post_to_pinterest_share': 'TEST_STATUS_FAILURE', 'tests.test_views.TestSocialSharing.test_post_to_facebook_share': 'TEST_STATUS_SUCCESS'}

It shouldn’t be the API limit error as I have tried after 3 hours of last request.``

Hey Nishanth, I am not sure why it reports API rate limit error as I have tried pushing the code after around 3-4 hours of making last request.
Also, I tried making a request immediately after the buld test and the request works fine.

The requests you make eat up the rate limit. Do wait for an hour more or head on to create new ones. I’m pretty sure either of them will work out. Patience is the key! :slight_smile: