There are 3 test cases in module three and after assessment of those files I get an error saying Facebook CLI and Facebook share are giving errors, but the same files successfully passed in module 2 !
Please help at the earliest!!
Here is my unit test log!
2020-03-02 09:11:56,395 unitTesting INFO Running pytest
2020-03-02 09:12:00,497 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: /csnehansh06-ME_QEATS_REVIEW_MP-d8bca846-5c65-11ea-976a-e35a92e0b338/csnehansh06-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 3 items
tests/test_views.py FF. [100%]
=================================== FAILURES ===================================
______________ TestSocialSharing.test_post_to_facebook_share_cli _______________
self = <tests.test_views.TestSocialSharing object at 0x3e3de289e400>
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)
tests/test_views.py:155:
self = <restaurants.facebook_post.Facebook object at 0x3e3de289e588>
message = ‘Assessment completed FACEBOOK CLI module! @ 2020-03-02 09:11:58.572638’
image_url = ‘http://ksmartstatic.sify.com/cmf-1.0.0/appflow/bawarchi.com/Image/oeturjecjjdah_bigger.jpg’
def publish_photo_msg(self, message, image_url):
params= (
('access_token',self.page_access_token),
)
E AttributeError: ‘Facebook’ object has no attribute ‘page_access_token’
restaurants/facebook_post.py:41: AttributeError
----------------------------- Captured stdout call -----------------------------
Assessment completed FACEBOOK CLI module! @ 2020-03-02 09:11:58.572638
________________ TestSocialSharing.test_post_to_facebook_share _________________
self = <tests.test_views.TestSocialSharing object at 0x3e3de289efd0>
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')
tests/test_views.py:180:
/usr/local/lib/python3.6/dist-packages/django/test/client.py:543: in post
response = super().post(path, data=data, content_type=content_type, secure=secure, **extra)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:357: in post
secure=secure, **extra)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:422: in generic
return self.request(**r)
/usr/local/lib/python3.6/dist-packages/django/test/client.py:503: in request
raise exc_value
/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py:34: in inner
response = get_response(request)
/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py:115: in _get_response
response = self.process_exception_by_middleware(e, request)
/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py:113: in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py:54: in wrapped_view
return view_func(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py:71: in view
return self.dispatch(request, *args, **kwargs)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:495: in dispatch
response = self.handle_exception(exc)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:455: in handle_exception
self.raise_uncaught_exception(exc)
/usr/local/lib/python3.6/dist-packages/rest_framework/views.py:492: in dispatch
response = handler(request, *args, **kwargs)
restaurants/views.py:219: in post
facebook.publish_photo_msg(message, image_url)
self = <restaurants.facebook_post.Facebook object at 0x3e3de734b5c0>
message = 'Great Work!!! Completed module 1 @ 2020-03-02 09:11:58.881786 #Facebook #Module1 ’
image_url = ‘https://i.imgur.com/kE2T5uv.jpg’
def publish_photo_msg(self, message, image_url):
params= (
('access_token',self.page_access_token),
)
E AttributeError: ‘Facebook’ object has no attribute ‘page_access_token’
restaurants/facebook_post.py:41: AttributeError
------------------------------ Captured log call -------------------------------
ERROR django.request:log.py:228 Internal Server Error: /qeats/v1/review/share
Traceback (most recent call last):
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py”, line 34, in inner
response = get_response(request)
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py”, line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File “/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py”, line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py”, line 71, in view
return self.dispatch(request, *args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 495, in dispatch
response = self.handle_exception(exc)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 455, in handle_exception
self.raise_uncaught_exception(exc)
File “/usr/local/lib/python3.6/dist-packages/rest_framework/views.py”, line 492, in dispatch
response = handler(request, *args, **kwargs)
File “/csnehansh06-ME_QEATS_REVIEW_MP-d8bca846-5c65-11ea-976a-e35a92e0b338/csnehansh06-ME_QEATS_REVIEW_MP/restaurants/views.py”, line 219, in post
facebook.publish_photo_msg(message, image_url)
File “/csnehansh06-ME_QEATS_REVIEW_MP-d8bca846-5c65-11ea-976a-e35a92e0b338/csnehansh06-ME_QEATS_REVIEW_MP/restaurants/facebook_post.py”, line 41, in publish_photo_msg
(‘access_token’,self.page_access_token),
AttributeError: ‘Facebook’ object has no attribute ‘page_access_token’
=============================== 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: /csnehansh06-ME_QEATS_REVIEW_MP-d8bca846-5c65-11ea-976a-e35a92e0b338/csnehansh06-ME_QEATS_REVIEW_MP/tests.xml -
==================== 2 failed, 1 passed, 1 warning in 2.22s ====================
2020-03-02 09:12:00,778 unitTesting INFO Pytest run complete
2020-03-02 09:12:00,795 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_FAILURE’}