text: #!/usr/bin/env python
  
  from pycamhd import lazycache as pycamhd
  import numpy as np
  from PIL import Image
  import random
  
  # remote file
  
  
  
  DEFAULT_FRAME_NUM=5000
  
  # This file is in the overlay on Berna
  filename_overlay = '/RS03ASHS/PN03B/06-CAMHDA301/2016/07/24/CAMHDA301-20160724T030000Z.mov'
  
  # This file is _not_ in the overlay on Berna
  filename_nonoverlay = '/RS03ASHS/PN03B/06-CAMHDA301/2016/11/13/CAMHDA301-20161113T000000Z.mov'
  
  test_lazycache = 'http://localhost:8080/v1/org/oceanobservatories/rawdata/files'
  
  def check_image(img, format=None, mode="RGBA"):
  
      if format is 'np':
          assert isinstance( img, np.ndarray )
  
          shape = img.shape
          assert shape[2] == 4   # RGBA?
          assert shape[1] == 1920
          assert shape[0] == 1080
          return
  
      ## For other formats, the object should be a PIL.Image.Image
      ## PIL only knows "JPEG", not 'JPG'
      format = "jpeg" if format == 'jpg' else format
  
      assert isinstance( img, Image.Image )
  
      assert img.width == 1920
      assert img.height == 1080
  
      if mode and format is "Image":
          assert img.mode == mode
      else:
          if format:
              assert img.format == format.upper()
  
  
  def do_get_frame(benchmark, filename, format):
      ## TODO:   This mechanism results in downloading the same frame_num repeatedly...
      ## Fix so it's actually downloading different images
      meta=pycamhd.get_metadata(test_lazycache+filename)
      img=benchmark(pycamhd.get_frame, test_lazycache + filename, frame_num=random.uniform(0,meta['NumFrames']), format=format)
      check_image(img,format)
  
  
  ## Could I generate these programmatically?
  
  def test_lazycache_np_overlay(benchmark):
      do_get_frame(benchmark, filename_overlay, "np")
  
  def test_lazycache_np_nonoverlay(benchmark):
      do_get_frame(benchmark, filename_nonoverlay, "np")
  
  def test_lazycache_PIL_Image_overlay(benchmark):
      do_get_frame(benchmark, filename_overlay, "Image")
  
  def test_lazycache_PIL_Image_nonoverlay(benchmark):
      do_get_frame(benchmark, filename_nonoverlay, "Image")
  
  def test_lazycache_bmp_overlay(benchmark):
      do_get_frame(benchmark, filename_overlay, "bmp")
  
  def test_lazycache_bmp_nonoverlay(benchmark):
      do_get_frame(benchmark, filename_nonoverlay, "bmp")
  
  def test_lazycache_jpg_overlay(benchmark):
      do_get_frame(benchmark, filename_overlay, "jpg")
  
  def test_lazycache_jpg_nonoverlay(benchmark):
      do_get_frame(benchmark, filename_nonoverlay, "jpg")
  
  def test_lazycache_png_overlay(benchmark):
      do_get_frame(benchmark, filename_overlay, "png")
  
  def test_lazycache_png_nonoverlay(benchmark):
      do_get_frame(benchmark, filename_nonoverlay, "png")
  