class SettingsReloadingTestCase(TestCase): def setUp(self): self.transport = AbortableStringTransport() self.factory = ConnectionFactory() self.factory.settings = ConnectionSettings({ 'channel #foo': {'enabled': True}, 'plugin {}'.format(NoticingPlugin.name): True}) self.connection = self.factory.buildProtocol(None) self.connection.reactor = Clock() self.connection.makeConnection(self.transport) self.connection.irc_RPL_WELCOME('irc.server.test', []) self.connection.joined('#foo') def test_joins_and_parts(self): self.connection.joined('#bar') self.transport.clear() self.factory.reload_settings({ 'channel #foo': {'enabled': False}, 'channel #bar': {'enabled': 'soft'}, 'channel #baz': {'enabled': 'soft'}, 'channel #quux': {'enabled': True}}) self.assertItemsEqual(self.transport.value().splitlines(), ['PART #foo', 'JOIN #quux']) def test_plugin_identity(self): old_plugin = self.factory.settings.active_plugins().keys()[0] self.factory.reload_settings({ 'channel #foo': {'enabled': True}, 'plugin {}'.format(NoticingPlugin.name): True}) new_plugin = self.factory.settings.active_plugins().keys()[0] self.assertIs(old_plugin, new_plugin)
def test_proxy_filebodyproducer(self): original = FileBodyProducer(BytesIO(LOREM_IPSUM)) proxy = RecordingBodyProducer(original) self.assertEqual(original.length, proxy.length) transport = AbortableStringTransport() yield proxy.startProducing(transport) self.assertEqual(transport.value(), LOREM_IPSUM) self.assertEqual(proxy.value(), LOREM_IPSUM)