errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 616 forks source link

error when running test_myplugin.py #266

Closed singhaidotnish closed 10 years ago

singhaidotnish commented 10 years ago

(sorry for this long mail. There was no way to attach text file here.)

  1. need: to send message to user in spark ( openfire server ) ( auto generated )
self.send("user@host.tld/resource", "Boo! Bet you weren't expecting me, were you?", message_type="chat")
  1. What I have done so far:

    run c:\Python27\Lib\site-packages\errbot>err.by (This is ok) (see link )

    and

    from a python console, following works

    from errbot.backends.test import FullStackTest, pushMessage, popMessage

    from errbot import plugin_manager

  2. What i have tried so far:

    test_myplugin.py which gives following error.

Point is, will 1. work even if 3. is not working. ( If it's needed for test_myplugin to work ) Then how do I rectify the errors. (sorry could not attach text file, so have to put it here...)

What will it take to successfully run point no 1 successfully.

Ran 4 tests in 5.916s

FAILED (failures=2, errors=1)

http://tny.cz/b9272ae7 ( complete listing of error )

errcommand

zoni commented 10 years ago

errbot.backends.test is a test-backend for use with unit tests. You don't need these to write plugins, they're just a method to write tests to ensure your code is working correctly.

If you just want to send a specific user a specific message, all you need is to write a plugin that uses self.send() to send the message when something specific happens. I've already made reference to that in #264.

singhaidotnish commented 10 years ago

Thank you for your reply. Sure i'll use self.send() to send message to user. How do i interpret this

"user@host.tld/resource" for me user - username host - where openfire service is running tld - ? resource - ?

Sorry although these are petty questions, since I have absolutely no clue i need your help. Thank you in advance.

zoni commented 10 years ago

user@host.tld/resource means a Jabber ID (JID) as defined in RFC 6122. In short, it is composed of:

For example, given I am nick on host groenen.me and I have configured my client to use the resource foobar, my full JID would be nick@groenen.me/foobar.

When sending a message to nick@groenen.me/foobar, it would arrive specifically on that client. The resource part may be omitted, however, so if I am connected with multiple clients, and you send only to nick@groenen.me, the message will be routed to the resource with the highest priority.

Multi user chat (MUC) rooms are addressed the same way.

singhaidotnish commented 10 years ago

Thank you for your reply. I tried a simple plugin that will only use self.send(...). Find attached image. (errbot_send.png) errbot_send

For test purpose, using this link (https://github.com/gbin/err/wiki/plugin-dev#testing), I realised that plugin_dir needs to be set. So,

class MyPluginTests(FullStackTest): def setUp(self): me = os.path.dirname(os.path.realpath(os.path.abspath(file)))

Adding /la/bla to path is needed because of the path mangling

    # FullStackTest does on extra_test_file.
    plugin_dir = os.path.join(me, 'la', 'bla')
    super(MyPluginTests, self).setUp(extra_test_file=plugin_dir)
    self.send("sayeed@server","bot test", message_type="chat")

a = MyPluginTests() a.setUp()

tried running this , I get following ( errbot_runtest.png ) error.

errbot_runtest

Kindly suggest. Thank you in advance.

singhaidotnish commented 10 years ago

Would i need to login :) ?

zoni commented 10 years ago

@singhainish I'm going to close this issue because you also posted to our Google+ page. Lets continue the conversation over there.