コード例 #1
0
  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)
コード例 #2
0
    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)
コード例 #3
0
    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)