def by_id(self, url, request): headers = create_quota_headers() content = { "title": self.fake.catch_phrase(), "nickname": "", "custom_variables": { "name": "label" }, "language": "en", "question_count": random.randint(1, 20), "page_count": random.randint(1, 20), "date_created": self.fake.iso8601(tzinfo=None), "date_modified": self.fake.iso8601(tzinfo=None), "id": self.survey_id, "pages": [{ "questions": [{}] }], "buttons_text": { "done_button": "Done", "prev_button": "Prev", "exit_button": "Exit", "next_button": "Next" }, "preview": "https://www.surveymonkey.com/r/Preview/", "edit_url": "https://www.surveymonkey.com/create/", "collect_url": "https://www.surveymonkey.com/collect/list", "analyze_url": "http://www.surveymonkey.com/analyze/3bOmrM5mtfgBEcubFSDvR_2FbJ_2BrGx0E4aEBPKvsYFo9E_3D", # noqa:E501 "summary_url": "https://www.surveymonkey.com/summary/" } return response(200, content, headers)
def within_daily_quota(self, url, request): headers = create_quota_headers() content = { 'message': 'This is a mocked request which is within the daily quota.' } return response(200, content, headers)
def exceeds_per_second_quota(self, url, request): headers = create_quota_headers(qps=(8, 9)) content = { 'message': 'This is a mocked request which exceeds the per second quota.' } return response(200, content, headers)
def exceeds_daily_quota(self, url, request): headers = create_quota_headers(qpd=(10000, 10001)) content = { 'message': 'This is a mocked request which exceeds the daily quota.' } return response(200, content, headers)
def create(self, url, request): id = str(random.randint(1, 9000)) headers = create_quota_headers() content = { "id": id, "name": self.fake.catch_phrase(), "event_type": self.event_type, "object_ids": self.object_ids, "subscription_url": self.subscription_url, "href": "{base_url}/{id}".format(base_url=URL_WEBHOOKS, id=id) } return response(200, content, headers)
def surveys_no_links(self, url, request): headers = create_quota_headers() per_page, current_page, pages = self.parse_url(url) data = self.create_surveys(per_page, current_page, pages) content = { "per_page": per_page, "total": self.total, "page": current_page, "data": data } return response(200, content, headers)
def _create_response(id, status_code, name, message): headers = create_quota_headers() content = { "error": { "docs": "https://developer.surveymonkey.com/api/v3/#error-codes", "message": message, "id": id, name: name, "http_status_code": status_code } } return response(status_code, content, headers)
def me(self, url, request): headers = create_quota_headers() content = { "id": str(random.randint(1, 9000)), "username": self.fake.user_name(), "first_name": self.fake.first_name(), "last_name": self.fake.last_name(), "language": "en", "email": self.fake.safe_email(), "account_type": "enterprise_platinum", "date_created": self.fake.iso8601(tzinfo=None), "date_last_login": self.fake.iso8601(tzinfo=None) } return response(200, content, headers)
def by_id(self, url, request): headers = create_quota_headers() content = { "total_time": 144, "ip_address": "192.168.4.16", "recipient_id": "", "id": "5007154402", "logic_path": {}, "metadata": {}, "date_modified": "2015-12-28T21:59:38+00:00", "response_status": "completed", "custom_variables": { "custvar_1": "one", "custvar_2": "two" }, "custom_value": "custom identifier for the response", "edit_url": "https://www.surveymonkey.com/r/", "analyze_url": "https://www.surveymonkey.com/analyze/browse/", "page_path": [], "pages": [{ "id": "103332310", "questions": [{ "answers": [{ "choice_id": "3057839051" }], "id": "319352786" }] }], "collector_id": "50253690", "date_created": "2015-12-28T21:57:14+00:00", "survey_id": "105724755", "collection_mode": "default" } return response(200, content, headers)
def list(self, url, request): headers = create_quota_headers() per_page, current_page, pages = self.parse_url(url) links = self.get_links(per_page, current_page, pages) data = self.create_items(per_page, current_page, pages) content = { "per_page": per_page, "total": self.total, "page": current_page, "data": data, "links": links } return response(200, content, headers)
def by_id(self, url, request): headers = create_quota_headers() content = { "status": "open", "id": self.collector_id, "type": self.type, "name": "My Collector", "thank_you_message": "Thank you for taking my survey.", "disqualification_message": "Thank you for taking my survey.", "close_date": self.fake.iso8601(tzinfo=None), "closed_page_message": "This survey is currently closed.", "redirect_url": "https://www.surveymonkey.com", "display_survey_results": False, "edit_response_type": "until_complete", "anonymous_type": "not_anonymous", "allow_multiple_responses": False, "date_modified": self.fake.iso8601(tzinfo=None), "url": "https://www.surveymonkey.com/r/2Q3RXZB", "date_created": "2015-10-06T12:56:55+00:00", "sender_email": None, "password_enabled": False, "href": "{base_url}/{id}".format(base_url=URL_COLLECTOR_SINGLE, id=self.collector_id) } return response(200, content, headers)
def recipient_add(self, url, request): headers = create_quota_headers() content = { "succeeded": [{ "id": str(random.randint(1234, 567890)), "email": self.fake.safe_email(), "href": "https://api.surveymonkey.net/v3/collectors/1234/recipients/1234" }], "invalids": [], "existing": [], "bounced": [], "opted_out": [], "duplicate": [] } return response(200, content, headers)
def send(self, url, request): headers = create_quota_headers() content = { "is_scheduled": True, "scheduled_date": self.fake.iso8601(tzinfo=None), "body": "<html>...</html>", "subject": "We want your opinion", "recipients": [ str(random.randint(12345, 67890)) for x in range(2, random.randint(5, 20)) ], "recipient_status": None, "type": "invite" } return response(200, content, headers)
def create(self, url, request): headers = create_quota_headers() content = self.config return response(200, content, headers)