Post to Facebook share and share cli tests failing

  1. Describe the issue briefly
    Tag Suggestions and Pinterest share is working but both tests for Facebook are failing.
    Following is the Unit Testing Log:

2020-02-03 12:09:41,723 unitTesting INFO Running pytest
2020-02-03 12:09:50,516 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: /keskarshreesh-ME_QEATS_REVIEW_MP-08f1d6e2-467e-11ea-8299-5dc518e197d9/keskarshreesh-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 4 items

tests/ .FF. [100%]

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

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

def test_post_to_facebook_share_cli(self):

    facebook = restaurants.facebook_post.Facebook()
    image_url = ''
    my_name = self.get_user_name()

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

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

E AssertionError: assert False
E + where False = <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3ec4194963c8>>(‘Assessment completed FACEBOOK CLI module! @ 2020-02-03 12:09:44.299873’, ‘’)
E + where <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3ec4194963c8>> = <tests.test_views.FacebookTestUtil object at 0x3ec4194963c8>.check_whether_message_is_published

tests/ AssertionError
----------------------------- Captured stdout call -----------------------------
Assessment completed FACEBOOK CLI module! @ 2020-02-03 12:09:44.299873
200 {‘id’: ‘121899472688146’}
Get user feed url =,message,attachments
________________ TestSocialSharing.test_post_to_facebook_share _________________

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

def test_post_to_facebook_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)
    message = 'Great Work!!! Completed module 1 @ {}'.format(str(
    request_body = {
                    'imgBase64' : img_b64.decode('utf-8'),
                    'text' : message,
                    'orderId' : '0x12312',
                    'tags' : ['Facebook', 'Module1'],
                    'share' : ['Facebook']

    resp ='/qeats/v1/review/share', data=request_body, content_type='application/json')
    assert resp.status_code == 200
    facebook_test_util = FacebookTestUtil()
    message_expected = message + ' #Facebook #Module1'
  assert facebook_test_util.check_whether_message_is_published(message_expected, image_path)

E AssertionError: assert False
E + where False = <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3ec414685d30>>(‘Great Work!!! Completed module 1 @ 2020-02-03 12:09:46.779231 #Facebook #Module1’, ‘/keskarshreesh-ME_QEATS_REVIEW_MP-08f1d6e2-467e-11ea-8299-5dc518e197d9/keskarshreesh-ME_QEATS_REVIEW_MP/tests/sneakpeak.jpg’)
E + where <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3ec414685d30>> = <tests.test_views.FacebookTestUtil object at 0x3ec414685d30>.check_whether_message_is_published

tests/ AssertionError
----------------------------- Captured stdout call -----------------------------
200 {‘id’: ‘121899522688141’}
Get user feed url =,message,attachments
=============================== 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: /keskarshreesh-ME_QEATS_REVIEW_MP-08f1d6e2-467e-11ea-8299-5dc518e197d9/keskarshreesh-ME_QEATS_REVIEW_MP/tests.xml -
    ==================== 2 failed, 2 passed, 1 warning in 6.99s ====================

2020-02-03 12:09:50,718 unitTesting INFO Pytest run complete
2020-02-03 12:09:50,738 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_tag_suggesstion’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_FAILURE’}

  1. How much time have you spent debugging this issue?
    (Please spend at least 15 minutes to resolve the issue on your own before posting a new topic here)
    1.5 hours

  2. What is your hypothesis?
    Unsure as previous modules are comlpeted

hey! dont just paste so much mess.
It is difficult to understand this. Try to post exact error and explain it so that we can help you

Hi @sanketvy thanks for your comment. The traceback is somewhat like below:

  assert facebook_test_util.check_whether_message_is_published(message_expected, image_path)
 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’

Hi, can someone please help? I can’t seem to find the solution to this issue and I’m not able to figure it out since the previous module where the image was to be posted to Facebook passed. Thanks!

I think the file seems to be faulty in my case, some imports are missing

The parameter published in has something wrong value in it.

Finally solved this issue! Thanks @Saurav_Crio.Do and @klmnitt for your help!
Referencing an issue which helped me solve this:

Although I am not sure how the Module 1 assessment passed for me earlier