tests.test_views.TestSocialSharing tests.test_views.TestSocialSharing

Need Help


What am i supposed to do?

Hi
looks like there is an error your code. try going through the log files for hints about your errors

The facebook_post.py is now showing me this issue
400 {‘error’: {‘message’: ‘Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.’, ‘type’: ‘OAuthException’, ‘code’: 190, ‘error_subcode’: 460, ‘fbtrace_id’: ‘A6o88JW5lLZC83U1M9fDUQ9’}}
but it worked in module 1

error code 190 usually means you are using an expired/invalid access token (https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling/ ).

Make sure you are not hardcoding the access token and you using the same one given by crio.do.

If that still doesn’t solve it, try contacting a member of the Crio.do team

No i haven’t hardcoded
It worked in the 1st module.Now i don’t know why its showing that error

2020-06-10 05:44:38,042 unitTesting INFO Running pytest
2020-06-10 05:44:50,166 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: /k-bhanuteja2001-ME_QEATS_REVIEW_MP-746da0fe-aadd-11ea-b9a7-3fe045fb2b62/k-bhanuteja2001-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 4 items

tests/test_views.py .FFs [100%]

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

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

def test_post_to_facebook_share_cli(self):

    facebook = restaurants.facebook_post.Facebook()
    image_url = 'https://hebbarskitchen.com/wp-content/uploads/2019/05/gadbad-ice-cream-recipe-gudbud-ice-cream-gadi-badi-ice-cream-2-1920x1280.jpeg'
    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)

E AssertionError: assert False
E + where False = <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3e09373d53c8>>(‘Assessment completed FACEBOOK CLI module! @ 2020-06-10 05:44:41.030829’, ‘https://hebbarskitchen.com/wp-content/uploads/2019/05/gadbad-ice-cream-recipe-gudbud-ice-cream-gadi-badi-ice-cream-2-1920x1280.jpeg’)
E + where <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3e09373d53c8>> = <tests.test_views.FacebookTestUtil object at 0x3e09373d53c8>.check_whether_message_is_published

tests/test_views.py:183: AssertionError
----------------------------- Captured stdout call -----------------------------
Assessment completed FACEBOOK CLI module! @ 2020-06-10 05:44:41.030829
200 {‘id’: ‘173851457501177’, ‘post_id’: ‘101534468074625_173851457501177’}
Get user feed url = https://graph.facebook.com/101534468074625/feed?access_token=EAAG8vdoul1cBANzlH8ZAGgJnuaTlR71EDAL4N6KZBJpeKkhCrs7nsKlFGSpsWw1Pa7MBfNeMft0tjZAoTrQXGyZBmN5brwZB9DbErmkV3eGQJIZBAo1cGZAw4HPlQGwGGdTHNECll8B449aIMwbxtKGf0UCY4lwz2eMktn5QN62QgFT65spR8VC&fields=id,message,attachments

{
“error”: {
“message”: “(#100) Pages Public Content Access requires either app secret proof or an app token”,
“type”: “OAuthException”,
“code”: 100,
“fbtrace_id”: “AarDUb5U8e6t4XgLwBPUADe”
}
}
________________ TestSocialSharing.test_post_to_facebook_share _________________

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

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(datetime.datetime.now()))
    request_body = {
                    'imgBase64' : img_b64.decode('utf-8'),
                    'text' : message,
                    'orderId' : '0x12312',
                    'tags' : ['Facebook', 'Module1'],
                    'share' : ['Facebook']
                    }

    resp = client.post(r'/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 0x3e09325b2d30>>(‘Great Work!!! Completed module 1 @ 2020-06-10 05:44:45.580881 #Facebook #Module1’, ‘/k-bhanuteja2001-ME_QEATS_REVIEW_MP-746da0fe-aadd-11ea-b9a7-3fe045fb2b62/k-bhanuteja2001-ME_QEATS_REVIEW_MP/tests/sneakpeak.jpg’)
E + where <bound method FacebookTestUtil.check_whether_message_is_published of <tests.test_views.FacebookTestUtil object at 0x3e09325b2d30>> = <tests.test_views.FacebookTestUtil object at 0x3e09325b2d30>.check_whether_message_is_published

tests/test_views.py:209: AssertionError
----------------------------- Captured stdout call -----------------------------
200 {‘id’: ‘173851487501174’, ‘post_id’: ‘101534468074625_173851487501174’}
Get user feed url = https://graph.facebook.com/101534468074625/feed?access_token=EAAG8vdoul1cBANzlH8ZAGgJnuaTlR71EDAL4N6KZBJpeKkhCrs7nsKlFGSpsWw1Pa7MBfNeMft0tjZAoTrQXGyZBmN5brwZB9DbErmkV3eGQJIZBAo1cGZAw4HPlQGwGGdTHNECll8B449aIMwbxtKGf0UCY4lwz2eMktn5QN62QgFT65spR8VC&fields=id,message,attachments

{
“error”: {
“message”: “(#100) Pages Public Content Access requires either app secret proof or an app token”,
“type”: “OAuthException”,
“code”: 100,
“fbtrace_id”: “A40sTtJ5BD8-gZs6iPE7slS”
}
}
=============================== 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: /k-bhanuteja2001-ME_QEATS_REVIEW_MP-746da0fe-aadd-11ea-b9a7-3fe045fb2b62/k-bhanuteja2001-ME_QEATS_REVIEW_MP/tests.xml -
    ============== 2 failed, 1 passed, 1 skipped, 1 warning in 10.09s ==============

2020-06-10 05:44:50,168 unitTesting INFO Pytest run complete
2020-06-10 05:44:50,171 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_facebook_share’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’}

THIS IS HOW MY LOG SHOWS

Hey @BhanuTej2001 make sure to copy the correct page access token. If it’s still not working then start it from scratch delete the app and delete the page, that works for me.

Dming you about this

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.