Skip to content

Commit

Permalink
unittest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehenneken committed Sep 25, 2020
1 parent e3516d6 commit ea8856a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions adsws/tests/stubdata/general_feedback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data = {'origin':'bbb_feedback','engine': u'Gecko', 'g-recaptcha-response': u'03AGdBq26IdCZUStucYY2tg4HR0X4PUoYutiiamENoDFrC9-kjBHV6CzuAxDSWWt8xn8p14WKtlvcQxHfhfNrmI-C_uoN8nUdbqJGy3T7ZxxkOaifTaD5CbQe-CeTKeUZYb4nHJYD4F3zIIVxNFyXK9wyzJT251ss-QNls3m9vt-ucHJwtPNlQ6EIkOfqLv5G3rOlZ0D-pZ17qybbWNo9PNFmEEWNiabdD01atIx8CIMjuhByPEbZYF7tH6lXGDscKfYTUqXEN9wLOadBv2yB-tA6UBCfBOQs8FD6szk1A7Q0GOd6juKL_O241z19ADNBsux21riOMw6UiPuDt8BI2yjEkjfoW3gdQkQp7j73FsIK5Gwb0C9SP7S34HJUuLt27QCmsp8NiXYu_k944U3KW_Rab9hcgUoix9ReXqqb2EJ6WT_W3mdeZh2fJumrRw5cdcaNmtESkONDH', 'feedback-type': u'feedback', '_gotcha': u'', 'user-agent-string': u'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0', '_subject': u'Bumblebee Feedback', 'current_query': u'filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc', 'browser.name': u'Firefox', 'name': u'Happy User', 'url': u'https://ui.adsabs.harvard.edu/search/filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc', 'current_page': u'search-page', 'comments': u'Hi,\r\n\r\n Thank you for maintaining this awesome service. Can you please give me more citations?\r\n\r\nThanks in advance,\r\nHappy User', 'platform': u'desktop', '_replyto': u'happyuser@happydomain.universe', 'os': u'Linux', 'currentuser': u'devost@cfht.hawaii.edu', 'browser.version': u'80.0'}
data = {'origin':'bbb_feedback','engine': u'Gecko', 'g-recaptcha-response': u'correct_response', 'feedback-type': u'feedback', '_gotcha': u'', 'user-agent-string': u'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0', '_subject': u'Bumblebee Feedback', 'current_query': u'filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc', 'browser.name': u'Firefox', 'name': u'Happy User', 'url': u'https://ui.adsabs.harvard.edu/search/filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc', 'current_page': u'search-page', 'comments': u'Hi,\r\n\r\n Thank you for maintaining this awesome service. Can you please give me more citations?\r\n\r\nThanks in advance,\r\nHappy User', 'platform': u'desktop', '_replyto': u'happyuser@happydomain.universe', 'os': u'Linux', 'currentuser': u'devost@cfht.hawaii.edu', 'browser.version': u'80.0'}

response = '**origin** bbb_feedback\n**engine** Gecko\n**feedback-type** feedback\n**_gotcha** \n**user-agent-string** Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0\n**_subject** Bumblebee Feedback\n**current_query** filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc\n**url** https://ui.adsabs.harvard.edu/search/filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc\n**current_page** search-page\n**comments** Hi,\r\n\r\n Thank you for maintaining this awesome service. Can you please give me more citations?\r\n\r\nThanks in advance,\r\nHappy User\n**platform** desktop\n**browser.name** Firefox\n**os** Linux\n**currentuser** devost@cfht.hawaii.edu\n**browser.version** 80.0\n'
response = '**origin** bbb_feedback\n**engine** Gecko\n**feedback-type** feedback\n**_gotcha** \n**user-agent-string** Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0\n**_subject** Bumblebee Feedback\n**current_query** filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc\n**url** https://ui.adsabs.harvard.edu/search/filter_property_fq_property=AND&filter_property_fq_property=property%3A%22refereed%22&fq=%7B!type%3Daqp%20v%3D%24fq_property%7D&fq_property=(property%3A%22refereed%22)&p_=0&q=year%3A2020%20%20full%3A%22cfht%22%20NOT%20docs(library%2FEyD7bWIGRNmxqCofTjNw4Q)%20NOT%20docs(library%2F49PdHlcMRh2_KF672dbcZw)&sort=date%20asc%2C%20bibcode%20asc\n**current_page** search-page\n**comments** Hi,\r\n\r\n Thank you for maintaining this awesome service. Can you please give me more citations?\r\n\r\nThanks in advance,\r\nHappy User\n**platform** desktop\n**browser.name** Firefox\n**os** Linux\n**currentuser** devost@cfht.hawaii.edu\n**browser.version** 80.0\n'
43 changes: 24 additions & 19 deletions adsws/tests/test_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,28 @@ def create_app(self):
"""
Create the wsgi application
"""
app_ = feedback.create_app()
app_ = feedback.create_app(
FEEDBACK_SLACK_END_POINT = 'https://hooks.slack.com/services/TOKEN/TOKEN',
FEEDBACK_SLACK_EMOJI = ':interrobang:',
FORM_SLACK_EMOJI = ':inbox_tray:',
DEFAULT_EMAIL = 'adshelp@cfa.harvard.edu',
FEEDBACK_FORMS_ORIGIN = 'user_submission',
BBB_FEEDBACK_ORIGIN = 'bbb_feedback',
FEEDBACK_TEMPLATES = {
'Missing References': 'missing_references.txt',
'Associated Articles': 'associated_articles.txt',
'Updated Record': 'updated_record.txt',
'New Record': 'new_record.txt',
'Bumblebee Feedback':'bumblebee_feedback.txt'
},
FEEDBACK_EMAILS = {
'Missing References': 'ads@cfa.harvard.edu',
},
MAIL_SUPPRESS_SEND=True,
GOOGLE_RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify',
GOOGLE_RECAPTCHA_PRIVATE_KEY = 'MY_PRIVATE_KEY'

)
return app_


Expand All @@ -150,21 +171,12 @@ def test_submitting_feedback(self):
A generic test of the entire work flow of the feedback submission
end point
"""
# User fills the user feedback form
form_data = {
'name': 'Commenter',
'comments': 'Why are my citations missing?',
'_replyto': 'commenter@email.com',
'g-recaptcha-response': 'correct_response',
'origin': 'bbb_feedback'
}

# User presses submit on the feedback form
url = url_for('userfeedback')
with SlackWebService() as SLW, GoogleRecaptchaService() as GRS:
response = self.client.post(
url,
data=form_data
data=json.dumps(general_feedback.data)
)
self.assertEqual(response.status_code, 200)

Expand Down Expand Up @@ -247,19 +259,12 @@ def test_submitting_feedback_with_minimal_information(self):
"""
Check they can send minimal information to the end point
"""
# User fills the user feedback form
form_data = {
'comments': 'Why are my citations missing?',
'g-recaptcha-response': 'correct_response',
'origin': 'bbb_feedback'
}

# User presses submit on the feedback form
url = url_for('userfeedback')
with SlackWebService() as SLW, GoogleRecaptchaService() as GRS:
response = self.client.post(
url,
data=form_data
data=json.dumps(general_feedback.data)
)
self.assertEqual(response.status_code, 200)

Expand Down

0 comments on commit ea8856a

Please sign in to comment.