def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name='fake_conn') fake_from = flexmock(name='fake_from') fake_from.should_receive('getStripped').and_return('me@public1') fake_event = flexmock(name='fake_event') fake_event.should_receive('getFrom').and_return(fake_from) fake_event.should_receive('getBody').and_return('doesnt matter') fake_event.should_receive('getType').and_return('chat') # and mock out the httplib call fake_response = flexmock(name='fake_response', status=200) fake_http_connection = flexmock(name='fake_http_connection') fake_http_connection.should_receive('request').with_args( 'POST', '/_ah/xmpp/message/chat/', str, XMPPReceiver.HEADERS) fake_http_connection.should_receive('getresponse').and_return( fake_response) fake_http_connection.should_receive('close').and_return() flexmock(httplib) httplib.should_receive('HTTPConnection').with_args('publicip1', 1234) \ .and_return(fake_http_connection) receiver = XMPPReceiver(self.appid, self.login_ip, self.load_balancer_ip, self.password) receiver.xmpp_message(fake_conn, fake_event)
def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name='fake_conn') fake_from = flexmock(name='fake_from') fake_from.should_receive('getStripped').and_return('me@public1') fake_event = flexmock(name='fake_event') fake_event.should_receive('getFrom').and_return(fake_from) fake_event.should_receive('getBody').and_return('doesnt matter') fake_event.should_receive('getType').and_return('chat') # and mock out the httplib call fake_response = flexmock(name='fake_response', status=200) fake_http_connection = flexmock(name='fake_http_connection') fake_http_connection.should_receive('request').with_args('POST', '/_ah/xmpp/message/chat/', str, XMPPReceiver.HEADERS) fake_http_connection.should_receive('getresponse').and_return(fake_response) fake_http_connection.should_receive('close').and_return() flexmock(httplib) httplib.should_receive('HTTPConnection').with_args('publicip1', 1234) \ .and_return(fake_http_connection) receiver = XMPPReceiver(self.appid, self.login_ip, self.load_balancer_ip, self.password) receiver.xmpp_message(fake_conn, fake_event)
def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name='fake_conn') fake_from = flexmock(name='fake_from') fake_from.should_receive('getStripped').and_return('me@public1') fake_event = flexmock(name='fake_event') fake_event.should_receive('getFrom').and_return(fake_from) fake_event.should_receive('getBody').and_return('doesnt matter') fake_event.should_receive('getType').and_return('chat') # mock out the curl call to the AppLoadBalancer, and slip in our own # ip to send the XMPP message to fake_curl = flexmock(name='curl_result') fake_curl.should_receive('read').and_return('Location: http://public2') flexmock(os) os.should_receive('popen').with_args(re.compile('curl')).and_return(fake_curl) # and finally mock out the urllib call flexmock(urllib) urllib.should_receive('urlopen').with_args( "http://public2/_ah/xmpp/message/chat/", str).and_return() receiver = XMPPReceiver(self.appid, self.login_ip, self.password) receiver.xmpp_message(fake_conn, fake_event)
def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name="fake_conn") fake_from = flexmock(name="fake_from") fake_from.should_receive("getStripped").and_return("me@public1") fake_event = flexmock(name="fake_event") fake_event.should_receive("getFrom").and_return(fake_from) fake_event.should_receive("getBody").and_return("doesnt matter") fake_event.should_receive("getType").and_return("chat") # and mock out the httplib call fake_response = flexmock(name="fake_response", status=200) fake_http_connection = flexmock(name="fake_http_connection") fake_http_connection.should_receive("request").with_args( "POST", "/_ah/xmpp/message/chat/", str, XMPPReceiver.HEADERS ) fake_http_connection.should_receive("getresponse").and_return(fake_response) fake_http_connection.should_receive("close").and_return() flexmock(httplib) httplib.should_receive("HTTPConnection").with_args("publicip1", 1234).and_return(fake_http_connection) receiver = XMPPReceiver(self.appid, self.login_ip, self.password) receiver.xmpp_message(fake_conn, fake_event)
def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name="fake_conn") fake_from = flexmock(name="fake_from") fake_from.should_receive("getStripped").and_return("me@public1") fake_event = flexmock(name="fake_event") fake_event.should_receive("getFrom").and_return(fake_from) fake_event.should_receive("getBody").and_return("doesnt matter") fake_event.should_receive("getType").and_return("chat") # and mock out the urllib call flexmock(urllib) urllib.should_receive("urlopen").with_args("http://publicip1:1234/_ah/xmpp/message/chat/", str).and_return() receiver = XMPPReceiver(self.appid, self.login_ip, self.app_port, self.password) receiver.xmpp_message(fake_conn, fake_event)
def test_message_results_in_post(self): # since we mock out the xmpp client in previous tests, we can't rely on it # to call the xmpp_message method. therefore, let's test it separately. fake_conn = flexmock(name='fake_conn') fake_from = flexmock(name='fake_from') fake_from.should_receive('getStripped').and_return('me@public1') fake_event = flexmock(name='fake_event') fake_event.should_receive('getFrom').and_return(fake_from) fake_event.should_receive('getBody').and_return('doesnt matter') fake_event.should_receive('getType').and_return('chat') # and mock out the urllib call flexmock(urllib) urllib.should_receive('urlopen').with_args( "http://publicip1:1234/_ah/xmpp/message/chat/", str).and_return() receiver = XMPPReceiver(self.appid, self.login_ip, self.app_port, self.password) receiver.xmpp_message(fake_conn, fake_event)