Пример #1
0
def test_get_url_private_caching_and_invalidation(botomock):

    mock_calls = []

    def mock_api_call(self, operation_name, api_params):
        assert operation_name == 'ListObjectsV2'
        mock_calls.append(api_params['Prefix'])
        return {
            'Contents': [{
                'Key': api_params['Prefix'],
            }],
        }

    urls = ('https://s3.example.com/private/prefix/', )
    downloader = SymbolDownloader(urls)
    with botomock(mock_api_call):
        assert downloader.get_symbol_url('xul.pdb',
                                         '44E4EC8C2F41492B9369D6B9A059577C2',
                                         'xul.sym')
        assert len(mock_calls) == 1
        assert downloader.get_symbol_url('xul.pdb',
                                         '44E4EC8C2F41492B9369D6B9A059577C2',
                                         'xul.sym')
        # This should be cached
        assert len(mock_calls) == 1

        # Now invalidate it
        downloader.invalidate_cache('xul.pdb',
                                    '44E4EC8C2F41492B9369D6B9A059577C2',
                                    'xul.sym')
        assert downloader.get_symbol_url('xul.pdb',
                                         '44E4EC8C2F41492B9369D6B9A059577C2',
                                         'xul.sym')
        assert len(mock_calls) == 2
Пример #2
0
def test_get_url_private_caching_and_invalidation(botomock):

    mock_calls = []

    def mock_api_call(self, operation_name, api_params):
        assert operation_name == "ListObjectsV2"
        mock_calls.append(api_params["Prefix"])
        return {"Contents": [{"Key": api_params["Prefix"]}]}

    urls = ("https://s3.example.com/private/prefix/", )
    downloader = SymbolDownloader(urls)
    with botomock(mock_api_call):
        assert downloader.get_symbol_url("xul.pdb",
                                         "44E4EC8C2F41492B9369D6B9A059577C2",
                                         "xul.sym")
        assert len(mock_calls) == 1
        assert downloader.get_symbol_url("xul.pdb",
                                         "44E4EC8C2F41492B9369D6B9A059577C2",
                                         "xul.sym")
        # This should be cached
        assert len(mock_calls) == 1

        # Now invalidate it
        downloader.invalidate_cache("xul.pdb",
                                    "44E4EC8C2F41492B9369D6B9A059577C2",
                                    "xul.sym")
        assert downloader.get_symbol_url("xul.pdb",
                                         "44E4EC8C2F41492B9369D6B9A059577C2",
                                         "xul.sym")
        assert len(mock_calls) == 2