def test_info_invalidate_cache(azure, second_azure): with azure_teardown(azure): # construct initial cache and ensure the file doesn't already exist assert not azure.exists(a, invalidate_cache=False) assert not second_azure.exists(a, invalidate_cache=False) with azure.open(a, 'wb') as f: f.write(b'a' * 5) # verify that it works in the fs that did the write and not on the other info = azure.info(a, invalidate_cache=False) with pytest.raises(FileNotFoundError): second_azure.info(a, invalidate_cache=False) # then invalidate second_info = second_azure.info(a, invalidate_cache=True) assert info['length'] == 5 assert info['name'] == a assert info['type'] == 'FILE' assert info['length'] == second_info['length'] assert info['name'] == second_info['name'] assert info['type'] == second_info['type'] # assure that the cache was properly repopulated on the info call assert second_azure.info(test_dir, invalidate_cache=False)['type'] == 'DIRECTORY'
def test_exists_remove_invalidate_cache(azure, second_azure): with azure_teardown(azure): # test to ensure file does not exist up front, cache doesn't matter assert not azure.exists(a, invalidate_cache=False) assert not second_azure.exists(a, invalidate_cache=False) azure.touch(a) # now ensure that it exists in the client that did the work, but not in the other assert azure.exists(a, invalidate_cache=False) assert not second_azure.exists(a, invalidate_cache=False) # now, with cache invalidation it should exist assert second_azure.exists(a, invalidate_cache=True) azure.rm(a) # same idea with remove. It should no longer exist (cache invalidated or not) in client 1, but still exist in client 2 assert not azure.exists(a, invalidate_cache=False) assert second_azure.exists(a, invalidate_cache=False) # now ensure it does not exist when we do invalidate the cache assert not second_azure.exists(a, invalidate_cache=True)