def test_post_data(self): # TEMPORARY test. Make sure we can post data. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.post("http://localhost/app/@@foo", "x=1&y=2") assert browser.contents == ( "Hi from SampleAppView, VARS: [(u'x', u'1'), (u'y', u'2')]")
def test_index_is_default_view(self): # the index view is called by default. receiver = ModifiedReceiver() receiver.validation_url = '' self.layer.getRootFolder()['app'] = receiver browser = Browser() # we do not give a view name here. browser.post("http://localhost/app", "got_it=1") assert receiver.call_args == 'got_it=1'
def test_post_data(self): # TEMPORARY test. Make sure we can post data. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.post("http://localhost/app/@@foo", "x=1&y=2") assert browser.contents == ( "Hi from SampleAppView, VARS: [(u'x', u'1'), (u'y', u'2')]" )
def test_index_calls_store_notification(self): # the index view informs the receiver. receiver = ModifiedReceiver() receiver.validation_url = '' self.layer.getRootFolder()['app'] = receiver browser = Browser() browser.post("http://localhost/app/@@index", "y=1&x=2") assert receiver.call_args == 'y=1&x=2' browser.post("http://localhost/app/@@index", "x=1&y=2") assert receiver.call_args == 'x=1&y=2'
def test_can_set_content_type(self): # TEMPORARY test. We can set the content type of a post request. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.handleErrors = False browser.post("http://localhost/app/@@bar", "x=1&y=2", "application/x-javascript") assert browser.contents == ("INPUT: x=1&y=2 " "CONTENT-TYPE application/x-javascript")
def test_can_set_content_type(self): # TEMPORARY test. We can set the content type of a post request. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.handleErrors = False browser.post("http://localhost/app/@@bar", "x=1&y=2", "application/x-javascript") assert browser.contents == ( "INPUT: x=1&y=2 " "CONTENT-TYPE application/x-javascript" )
def test_notify_view_validation_valid(self): # we can get successful validations with notify receiver = PayPalIPNReceiver() receiver.validation_url = self.layer.server.url root = self.layer.getRootFolder() root['app'] = receiver browser = Browser() browser.post('http://localhost/app/@@index', 'x=2') sent_body = self.layer.server.last_request_body assert browser.headers.get("status") == "200 Ok" assert sent_body == 'cmd=_notify-validate&x=2' assert len(list(receiver.keys())) == 1 notification = receiver[receiver.keys()[0]] assert notification.final_verdict == u'VERIFIED'
def test_can_access_post_data_line(self): # TEMPORARY test. We can access the body line with the post data. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.handleErrors = False browser.post("http://localhost/app/@@bar", "x=1&y=2") assert browser.contents == ( "INPUT: x=1&y=2 " "CONTENT-TYPE application/x-www-form-urlencoded") browser.post("http://localhost/app/@@bar", "y=1&x=2") assert browser.contents == ( "INPUT: y=1&x=2 " "CONTENT-TYPE application/x-www-form-urlencoded")
def test_can_access_post_data_line(self): # TEMPORARY test. We can access the body line with the post data. app = SampleApp() self.layer.getRootFolder()['app'] = app browser = Browser() browser.handleErrors = False browser.post("http://localhost/app/@@bar", "x=1&y=2") assert browser.contents == ( "INPUT: x=1&y=2 " "CONTENT-TYPE application/x-www-form-urlencoded" ) browser.post("http://localhost/app/@@bar", "y=1&x=2") assert browser.contents == ( "INPUT: y=1&x=2 " "CONTENT-TYPE application/x-www-form-urlencoded" )