GitHub PullRequestReviewCommentEvent at 2014-06-02 20:50:29
Repository: big-brother-bot
Actor: FenixXx
Payload: {"comment":{"url":"https://api.github.com/repos/BigBrotherBot/big-brother-bot/pulls/comments/13306375","id":13306375,"diff_hunk":"@@ -193,4 +196,73 @@ def test_register_event_with_valid_hook(self):\n         self.assertIn(k, self.console._handlers.keys())\n         self.assertIn(p, self.console._handlers[k])\n         self.assertIn(k, p.eventmap.keys())\n-        self.assertEqual(p.eventmap[k], p.stub_method)\n+        self.assertIn(p.stub_method, p.eventmap[k])\n+\n+    def test_register_event_with_sequential_valid_hooks(self):\n+        # GIVEN\n+        k = self.console.getEventID('EVT_CLIENT_SAY')\n+        p = MyPlugin(self.console, self.conf)\n+        p.registerEvent(k, p.stub_method)\n+        p.registerEvent(k, p.stub_method2)\n+        # THEN\n+        self.assertIn(k, self.console._handlers.keys())\n+        self.assertIn(p, self.console._handlers[k])\n+        self.assertIn(k, p.eventmap.keys())\n+        self.assertIn(p.stub_method, p.eventmap[k])\n+        self.assertIn(p.stub_method2, p.eventmap[k])\n+\n+    def test_register_event_with_sequential_valid_and_invalid_hooks(self):\n+        # GIVEN\n+        k = self.console.getEventID('EVT_CLIENT_SAY')\n+        p = MyPlugin(self.console, self.conf)\n+        p.registerEvent(k, p.stub_method)\n+        p.registerEvent(k, p.stub_not_callable)\n+        # THEN\n+        self.assertIn(k, self.console._handlers.keys())\n+        self.assertIn(p, self.console._handlers[k])\n+        self.assertIn(k, p.eventmap.keys())\n+        self.assertIn(p.stub_method, p.eventmap[k])\n+        self.assertNotIn(p.stub_method2, p.eventmap[k])\n+\n+    def test_register_event_with_list_of_valid_hooks(self):\n+        # GIVEN\n+        k = self.console.getEventID('EVT_CLIENT_SAY')\n+        p = MyPlugin(self.console, self.conf)\n+        p.registerEvent(k, p.stub_method, p.stub_method2)\n+        # THEN\n+        self.assertIn(k, self.console._handlers.keys())\n+        self.assertIn(p, self.console._handlers[k])\n+        self.assertIn(k, p.eventmap.keys())\n+        self.assertIn(p.stub_method, p.eventmap[k])\n+        self.assertIn(p.stub_method2, p.eventmap[k])\n+\n+    def test_register_event_with_list_of_valid_and_invalid_hooks(self):\n+        # GIVEN\n+        k = self.console.getEventID('EVT_CLIENT_SAY')\n+        p = MyPlugin(self.console, self.conf)\n+        p.registerEvent(k, p.stub_method, p.stub_not_callable)\n+        # THEN\n+        self.assertIn(k, self.console._handlers.keys())\n+        self.assertIn(p, self.console._handlers[k])\n+        self.assertIn(k, p.eventmap.keys())\n+        self.assertIn(p.stub_method, p.eventmap[k])\n+        self.assertNotIn(p.stub_method2, p.eventmap[k])\n+\n+    def test_parse_registered_event_with_multiple_valid_hooks(self):\n+        # GIVEN\n+        k = self.console.getEventID('EVT_CLIENT_SAY')\n+        p = MyPlugin(self.console, self.conf)\n+        p.registerEvent(k, p.stub_method)   # register the first hook","path":"tests/test_plugin.py","position":78,"original_position":78,"commit_id":"f0142480473d0559d92cfcb0298fa1c93a85e127","original_commit_id":"f0142480473d0559d92cfcb0298fa1c93a85e127","user":{"login":"FenixXx","id":1245124,"avatar_url":"https://avatars.githubusercontent.com/u/1245124?","gravatar_id":"877eef2276c4e85b1d200f32556f006a","url":"https://api.github.com/users/FenixXx","html_url":"https://github.com/FenixXx","followers_url":"https://api.github.com/users/FenixXx/followers","following_url":"https://api.github.com/users/FenixXx/following{/other_user}","gists_url":"https://api.github.com/users/FenixXx/gists{/gist_id}","starred_url":"https://api.github.com/users/FenixXx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FenixXx/subscriptions","organizations_url":"https://api.github.com/users/FenixXx/orgs","repos_url":"https://api.github.com/users/FenixXx/repos","events_url":"https://api.github.com/users/FenixXx/events{/privacy}","received_events_url":"https://api.github.com/users/FenixXx/received_events","type":"User","site_admin":false},"body":"The test will then not pass because the event mapping function checks for the method given to be a callable of the plugin itself (I tested it the way you said and the test was failing). Currently all the tests are passing on my Macbook and I tested it personally on a game server (no errors so far).\r\n\r\nonEvent() is not supposed to be called if there is a hook defined for the event: at least I see it this way.In plugins I always implement hooks and also the onEvent() method so the plugin is compatible with B3 1.9.x. The way you want to handle parseEvent will result in parsing the same event 2 times by the same plugin (example: https://github.com/FenixXx/b3-plugin-location/blob/master/extplugins/location.py#L127)\r\n\r\nAbout Mock imported from mockito...I have no idea where it came from, I guess I just typed to fast and used too much autocomplete ^_^","created_at":"2014-06-02T20:50:29Z","updated_at":"2014-06-02T20:50:29Z","html_url":"https://github.com/BigBrotherBot/big-brother-bot/pull/193#discussion_r13306375","pull_request_url":"https://api.github.com/repos/BigBrotherBot/big-brother-bot/pulls/193","_links":{"self":{"href":"https://api.github.com/repos/BigBrotherBot/big-brother-bot/pulls/comments/13306375"},"html":{"href":"https://github.com/BigBrotherBot/big-brother-bot/pull/193#discussion_r13306375"},"pull_request":{"href":"https://api.github.com/repos/BigBrotherBot/big-brother-bot/pulls/193"}}}}