Closed ppinzon closed 3 years ago
Ok, so I found the problem:
The method used to send the message in pytest only accepts one argument which is used a the text of the message https://github.com/errbotio/errbot/blob/54542fd38250b4cb977283854c5cb2b446b1281b/errbot/backends/test.py#L333
And once here, the message is pulled from the queue, the only fields updated are the To and From https://github.com/errbotio/errbot/blob/54542fd38250b4cb977283854c5cb2b446b1281b/errbot/backends/test.py#L266
I tried to update the attribute msg.extras but the property doesn't have a setter so it cant be updated. Instead i also tried adding it to object creation as a keyword argument and that seems to work great. by changing line 267 to msg = Message(entry, extras=extras). I also had extra in all the other methods that eventually end up there.
Would this be an acceptable change to create a PR?
Made a PR to show what I added for this to work. https://github.com/errbotio/errbot/pull/1489.
nvm, looks like I goofed something and the checks are failing.
PR passing the checks succesfully now
this being my first PR here I'm not that familiar with the lifecycle of this repo. How long, on average, does it take for this to be reviewed?
I appreciate your PR. We really don't have a specific time frame to review PRs. I try to spend a few days a month reviewing issues as free time allows.
cool beans, thank you Sijis
Closed via https://github.com/errbotio/errbot/pull/1489.
In order to let us help you better, please fill out the following fields as best you can:
I am...
I am running...
Issue description
Hello!
We use errbot with Slack. One of the pluggins that we have is used to capture a channel ID and store it. The channel information is given by the user just putting the channel name and slack fills up the details.
These are then sent to the bot as a message with an attachment. The bot sees this in msg.extras
Now, my problem is that im writting tests for this plugin but the function testbot.push_message() doesnt add the attachment by itself. Now, I could create the attachment manually but doesn't look like push_message takes any more arguments to add an attachment.
Is there another way to send an attachment for tests for Slack?
Steps to reproduce
Not a bug, but you can easily repo this:
create a plugin and add this for logging:
self.log.debug(msg) self.log.debug(msg.extras)
in slack, send a message to the bot mentioning a channel. e.g. !command this is my channel #mychannel
you will see msg.extras populated with the channel info
write a test for that command:
testbot.push_message('!command this is my channel #mychannel')
msg,extras will show up empty
Additional info
If you have any more information, please specify it here.