Tests using the Remote Data Manager#

A pytest fixture (sunpy_cache) is provided for ease of mocking network requests when using cache. The following example demonstrates the usage of the fixture:

def test_function():
    return manager.get('test_file')

def local_cache(sunpy_cache):
    sunpy_cache = sunpy_cache('sunpy.test_module.cache')

The above snippet creates a pytest fixture called local_cache. This fixture can be used in wherever the files have to be mocked. An example is given below:

def test_test_function(local_cache):
    # inside this function the mocked cache is used

    # test_function uses 'http://example.com/test_file'
    assert test_function() == True