def test_handler(self): self.failUnlessRaises(KeyError, QUERY_HANDLER.get_plugin, 'fake') QUERY_HANDLER.plugin_enable(fake_plugin) self.failUnless( isinstance(QUERY_HANDLER.get_plugin('fake'), FakeQueryPlugin)) QUERY_HANDLER.plugin_disable(fake_plugin) self.failUnlessRaises(KeyError, QUERY_HANDLER.get_plugin, 'fake')
def test_extension_search(self): plugin = Plugin(self.FakeQueryPlugin) QUERY_HANDLER.plugin_enable(plugin) song = AudioFile({"~filename": "/dev/null"}) try: assert Query("@(name: LIVE)").search(song) assert not Query("@(name: DIE)").search(song) finally: QUERY_HANDLER.plugin_disable(plugin)
def test_extension(self): plugin = Plugin(self.FakeQueryPlugin) QUERY_HANDLER.plugin_enable(plugin) try: assert Query("@(name)").valid assert not Query("@(name: DIE)").search("foo") assert Query("@(name: extension body)").valid assert Query("@(name: body (with (nested) parens))").valid assert Query(r"@(name: body \\ with \) escapes)").valid finally: QUERY_HANDLER.plugin_disable(plugin)