2020-03-03 16:17:44,032 unitTesting INFO Running pytest
2020-03-03 16:17:55,863 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: /gauravthakkar27-ME_QEATS_REVIEW_MP-7e92dd08-5d6a-11ea-97eb-e35a92e0b338/gauravthakkar27-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 3 items
tests/test_views.py …F [100%]
=================================== FAILURES ===================================
________________ TestSocialSharing.test_post_to_pinterest_share ________________
self = <tests.test_views.TestSocialSharing object at 0x3e416c1f5978>
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)
tests/test_views.py:210:
self = <tests.test_views.PinterestTestUtil object at 0x3e416c1f5f28>
message = ‘Great Work!!! Completed module 2 @ 2020-03-03 16:17:54.131745 #Pinterest #Module2’
image_path = ‘/gauravthakkar27-ME_QEATS_REVIEW_MP-7e92dd08-5d6a-11ea-97eb-e35a92e0b338/gauravthakkar27-ME_QEATS_REVIEW_MP/tests/sneakpeak.jpg’
def check_whether_message_is_published(self, message, image_path):
user_pins = self.get_all_pins_from_board()
if 'data' not in user_pins:
print('=' * 100)
print('\n\n\nPinterest API: Looks you have hit the per hour API limit\n\n\n')
print('=' * 100)
return False
for one_pin in user_pins['data']:
E TypeError: ‘NoneType’ object is not iterable
tests/test_views.py:85: TypeError
----------------------------- Captured stdout call -----------------------------
201 {‘data’: {‘id’: ‘817544138594461658’, ‘link’: ‘’, ‘note’: ‘Great Work!!! Completed module 2 @ 2020-03-03 16:17:54.131745 #Pinterest #Module2’, ‘url’: ‘https://www.pinterest.com/pin/817544138594461658/’}}
=============================== 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: /gauravthakkar27-ME_QEATS_REVIEW_MP-7e92dd08-5d6a-11ea-97eb-e35a92e0b338/gauravthakkar27-ME_QEATS_REVIEW_MP/tests.xml -
==================== 1 failed, 2 passed, 1 warning in 9.85s ====================
2020-03-03 16:17:56,094 unitTesting INFO Pytest run complete
2020-03-03 16:17:56,124 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_SUCCESS’}
LOG FILE END****
I can manually post pins by running the pinterest_post.py from terminal but failing the test cases.Also I did wait for an hour and verified that exceeding the api call limit was not the error.