def test_disable_plugins(plugins, db): client = Mock() plugins.all_plugins = ['foobar'] rec = {'plugin': 'foobar', 'channels': ['#all', '#bots']} db.auto_enabled_plugins.find_one.return_value = rec manager.disable_plugins(client, '#bots', 'foobar') assert db.auto_enabled_plugins.save.called assert '#bots' not in rec['channels']
def test_disable_plugins_no_plugins(filter_valid): snowman = u'☃' filter_valid.return_value = [] plugins = ['foo', 'bar', snowman] # Test unicode resp = manager.disable_plugins(None, None, *plugins) expect = u"Sorry, but I don't know about these plugins: {0}, {1}, {2}".format('foo', 'bar', snowman) assert resp == expect
def test_disable_plugins_no_plugins(filter_valid): snowman = u'☃' filter_valid.return_value = [] plugins = ['foo', 'bar', snowman] # Test unicode resp = manager.disable_plugins(None, None, *plugins) expect = u"Sorry, but I don't know about these plugins: {0}, {1}, {2}".format( 'foo', 'bar', snowman) assert resp == expect
def test_disable_plugins(plugins, db, filter_valid): client = Mock() plugins.all_plugins = ['foobar', 'blah', 'no_record'] filter_valid.return_value = plugins.all_plugins records = [ { # This will be removed 'plugin': 'foobar', 'channels': ['#all', '#bots'] }, { # Not enabled for the channel 'plugin': 'blah', 'channels': ['#other'], }, None # No plugin found ] db.auto_enabled_plugins.find_one.side_effect = records manager.disable_plugins(client, '#bots', *plugins.all_plugins) db.auto_enabled_plugins.save.assert_called_with(records[0]) assert '#bots' not in records[0]['channels']