async def test_when_fetch_fails_bad_repo(self, loop):
        handler = WordPressRepository(loop=loop,
                                      storage=MagicMock(),
                                      repository_checker=MagicMock())
        handler.current_plugins = lambda: {'hello-world', 'unknown-plugin'}
        handler.enumerate_plugins = lambda: fake_future(
            {'hello-world', 'a', 'b'}, loop)

        handler.fetch_plugin = MagicMock()
        handler.fetch_plugin.side_effect = PluginNotFound('A side effect!')
        handler.checker.has_content.return_value = fake_future(False, loop)
        await handler.perform_plugin_lookup()

        handler.fetch_plugin.assert_has_calls([
            call('a'),
            call('b'),
        ],
                                              any_order=True)
        handler.storage.write_meta.assert_not_called()
        handler.checker.has_content.assert_has_calls([
            call(
                Repository(type="subversion",
                           location="https://plugins.svn.wordpress.org/a/")),
            call(
                Repository(type="subversion",
                           location="https://plugins.svn.wordpress.org/b/")),
        ],
                                                     any_order=True)
        handler.storage.append.assert_has_calls([
            call("plugins-ignore.txt", "a"),
            call("plugins-ignore.txt", "b"),
        ],
                                                any_order=True)
    async def test_no_calls_made_when_nothing_new(self, loop):
        handler = WordPressRepository(loop=loop)
        handler.current_plugins = lambda: {'hello-world', 'unknown-plugin'}
        handler.enumerate_plugins = lambda: fake_future({'hello-world'}, loop)

        handler.fetch_plugin = MagicMock()
        handler.fetch_plugin.assert_not_called()
        await handler.perform_plugin_lookup()
    async def test_calls_made_when_new_plugins_arrive(self, loop):
        handler = WordPressRepository(loop=loop, storage=MagicMock())
        handler.current_plugins = lambda: {'hello-world', 'unknown-plugin'}
        handler.enumerate_plugins = lambda: fake_future({'hello-world', 'a', 'b'}, loop)

        handler.fetch_plugin = MagicMock()
        handler.fetch_plugin.return_value = fake_future(Meta(key="a", name="A"), loop)
        await handler.perform_plugin_lookup()

        handler.fetch_plugin.assert_has_calls([
            call('a'),
            call('b'),
        ], any_order=True)
        handler.storage.write_meta.assert_called_with(Meta(key="a", name="A"))