def it_should_call_save_on_the_contact(mock_save): rf = helper.RequestFactory() mock_save.return_value = [{'status': '200'}, None] mock_request = rf.post('/notify/', dict(body=recurly_xml)) response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_save.called
def it_errors_if_apikey_wrong(): from recurly_parse_spec import recurly_successful_payment rf = helper.RequestFactory() mock_request = rf.post('/notify/', dict(body=recurly_successful_payment)) response = notify(mock_request, "sdfsdfsd") assert response.status_code == 403
def it_should_call_save_on_the_invoice(mock_save): from recurly_parse_spec import recurly_successful_payment mock_save.return_value = [{'status': '200'}, None] rf = helper.RequestFactory() mock_request = rf.post('/notify/', dict(body=recurly_successful_payment)) response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_save.called
def it_should_call_save_on_the_contact(mock_save): rf = helper.RequestFactory() mock_save.return_value = [{'status':'200'}, None] mock_request = rf.post('/notify/', data=recurly_xml.strip(), content_type='text/xml') response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_save.called
def it_should_call_save_on_the_invoice(mock_save): from recurly_parse_spec import recurly_successful_payment mock_save.return_value = [{'status':'200'}, None] rf = helper.RequestFactory() mock_request = rf.post('/notify/', data=recurly_successful_payment.strip(), content_type='text/xml') response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_save.called
def it_should_pass_the_notification_to_the_notification_parser(mock_parse): class TestObject: def save(self): return [{'status': '200'}, None] rf = helper.RequestFactory() mock_parse.return_value = TestObject() mock_request = rf.post('/notify/', dict(body=recurly_xml)) response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_parse.called
def it_should_pass_the_notification_to_the_notification_parser(mock_parse): class TestObject: def save(self): return [{'status':'200'}, None] rf = helper.RequestFactory() mock_parse.return_value = TestObject() mock_request = rf.post('/notify/', dict(body=recurly_xml)) response = notify(mock_request, settings.RECURLY_API_KEY) assert response.status_code == 200 assert mock_parse.called
def it_errors_if_apikey_wrong(): from recurly_parse_spec import recurly_successful_payment rf = helper.RequestFactory() mock_request = rf.post('/notify/', dict(body=recurly_successful_payment)) response = notify(mock_request, "sdfsdfsd") assert response.status_code == 403