@patch('pypicloud.views.api.fetch_dist')
    def test_download_fallback_cache(self, fetch_dist):
        """ Downloading missing package caches result from fallback """
        db = self.request.db = MagicMock()
        locator = self.request.locator = MagicMock()
        self.request.registry.fallback = 'cache'
        self.request.registry.fallback_url = 'http://pypi.com'
        self.request.access.can_update_cache.return_value = True
        db.fetch.return_value = None
        fetch_dist.return_value = (MagicMock(), MagicMock())
        context = MagicMock()
        context.filename = 'package.tar.gz'
        dist = MagicMock()
        url = context.filename % 'http://pypi.com/simple/%s'
        locator.get_project.return_value = {
            '0.1': dist,
            'urls': {
                '0.1': set([url])
            }
        }
        ret = api.download_package(context, self.request)
        fetch_dist.assert_called_with(self.request, dist.name, url)
        self.assertEqual(ret.body, fetch_dist()[1])
dataset/ETHPy150Open mathcamp/pypicloud/tests/test_api.py/TestApi.test_download_fallback_cache/swapped operands of `%`