Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created August 18, 2016 02:20
Show Gist options
  • Save jrabbit/8cbec7443ee8d3deb3c2f8fac6ab7c5e to your computer and use it in GitHub Desktop.
Save jrabbit/8cbec7443ee8d3deb3c2f8fac6ab7c5e to your computer and use it in GitHub Desktop.
@mock.patch('random.choice')
def test_nick_replace(self, patched_choice):
mod = pyborg_irc2.ModIRC(pyborg.pyborg.pyborg, self.settings)
our_event = irc.client.Event(type=None, source=None, target="#botally")
mocked_channel = mock.Mock()
patched_choice.return_value = "jrabbit"
# mocked_channel.return_value.users = ['jrabbit']
# mocked_channel.users.return_value = ["jrabbit"]
mod.channels = {"#botally": mocked_channel}
msg = "#nick is the best bot maker!"
output = mod.replace_nicks(msg, our_event)
mocked_channel.users.assert_called_with()
self.assertEqual(output, "jrabbit is the best bot maker!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment