Getting status code 200 and both id and post id but still failing assessment

please have a look at log files
2020-01-25 11:52:01,751 unitTesting INFO Running pytest
2020-01-25 11:52:14,100 unitTesting INFO ============================= test session starts ==============================
platform linux – Python 3.6.9, pytest-5.3.1, py-1.8.0, pluggy-0.12.0
rootdir: /pawanraip4-ME_QEATS_REVIEW_MP-14753052-3f69-11ea-b236-91959715a45e/pawanraip4-ME_QEATS_REVIEW_MP
plugins: django-3.5.1, mock-1.10.4
collected 1 item

tests/test_views.py F [100%]

=================================== FAILURES ===================================
______________ TestSocialSharing.test_post_to_facebook_share_cli _______________

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

def test_post_to_facebook_share_cli(self):

    facebook = restaurants.facebook_post.Facebook()
    image_url = 'http://ksmartstatic.sify.com/cmf-1.0.0/appflow/bawarchi.com/Image/oeturjecjjdah_bigger.jpg'
    my_name = self.get_user_name()

    message = my_name + ' completed FACEBOOK CLI module! @ {}'.format(str(datetime.datetime.now()))
    print(message)
    facebook.publish_photo_msg(message, image_url)

    facebook_test_util = FacebookTestUtil()
  assert facebook_test_util.check_whether_message_is_published(message, image_url)

tests/test_views.py:119:


self = <tests.test_views.FacebookTestUtil object at 0x3e9a214b25c0>
message = ‘Assessment completed FACEBOOK CLI module! @ 2020-01-25 11:52:07.488488’
image_path = ‘http://ksmartstatic.sify.com/cmf-1.0.0/appflow/bawarchi.com/Image/oeturjecjjdah_bigger.jpg

def check_whether_message_is_published(self, message, image_path):
    user_feeds = self.get_user_feed()

    if 'error' in user_feeds:
        print("\n\n",json.dumps(user_feed, indent=4))
        return False
    for feed in user_feeds['data']:
        if 'attachments' in feed:
          if feed['message'] == message:

E KeyError: ‘message’

tests/test_views.py:82: KeyError
----------------------------- Captured stdout call -----------------------------
Assessment completed FACEBOOK CLI module! @ 2020-01-25 11:52:07.488488
200 {‘id’: ‘110485803834118’, ‘post_id’: ‘112484523614558_110485803834118’}
Get user feed url = https://graph.facebook.com/109239790625386/feed?access_token=EAACmZB4wIJ1IBAJs1lGapZCdhNdTn1gPPOJbKSFj0VVUC1sXC2bqAGrbYp5cTTEhK2GitvTD0PXA6668l0sBn91xkwL4dwBrtCV9QVlCCxFKbZArE9F0wfQcXAiB0DDqK6Gw2uOPfo6R6JtXFugB4ZByj7ZCZAOZAyTPxvbCyIJOQZDZD&fields=id,message,attachments
=============================== 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: /pawanraip4-ME_QEATS_REVIEW_MP-14753052-3f69-11ea-b236-91959715a45e/pawanraip4-ME_QEATS_REVIEW_MP/tests.xml -
    ========================= 1 failed, 1 warning in 9.51s =========================

2020-01-25 11:52:14,101 unitTesting INFO Pytest run complete
2020-01-25 11:52:14,103 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_FAILURE’}

Another qustion similar to this has been posted. Try looking into this

same problem but not able get reason where i am going wrong

I checked. Your request format is not proper. Make sure not to hard code the values. Try referring to this.

https://crio-lmp250120-01.slack.com/archives/CSKJ7L73L/p1579952227063100

i am doing same as given in this link passing message ,image_url, access token only page_id is hardcoded between link