Beispiel #1
0
 def on_line(self, line):
     r = router.router(( (r"^add network\s+(.*?)\s+(.*?)$",         self._add_network),
                         (r"^set network\s+(.*?)\s+(.*?)$",         self._set_network),
                         (r"^show enclosure\s*$",                   self._show_enclosure),
                         (r"^set enet-connection\s+(.*?)\s+(.*?)$", self._set_enetconnection)
                       ), self._missing)
     r.dispatch(line)
     self._endl()
     self._prompt()
Beispiel #2
0
 def test_dispatch_gives_the_line_that_originated_the_event_plus_the_matching_groups(self):
     m = mock.Mock()
     r = router.router(((r"^foo(bar)$", m),), "default")
     r.dispatch("foobar")
     m.assert_called_with("foobar", "bar")
Beispiel #3
0
 def on_line(self, line):
     r = router.router(( (r"^ping$", self._pong),
                       ), self._missing)
     r.dispatch(line)
     self._endl()
     self._prompt()
Beispiel #4
0
 def test_dispatch_gives_the_line_that_originated_the_event(self):
     m = mock.Mock()
     r = router.router((), m)
     r.dispatch("foobar")
     m.assert_called_with("foobar")
Beispiel #5
0
 def test_find_action_returns_matching_groups(self):
     r = router.router(((r"^foo(bar)$", "success"),), "default")
     self.assertEqual(("success", ("bar",)), r.find_action("foobar"))
Beispiel #6
0
 def test_find_action_uses_default_route(self):
     r = router.router((), "default")
     self.assertEqual(("default",()), r.find_action("foobar"))
Beispiel #7
0
 def test_find_action_uses_routes_as_regexp(self):
     r = router.router(((r"^foobar$", "success"),), "default")
     self.assertEqual(("success",()), r.find_action("foobar"))
Beispiel #8
0
 def test_init(self):
     r = router.router("router", "default")
     self.assertEqual("router", r.routes)
     self.assertEqual("default", r.default)