code: def test_download(api, tmpdir, smallest_online_products):
      product = smallest_online_products[0]
      uuid = product["id"]
      title = product["title"]
      expected_path = tmpdir.join(title + ".zip")
      tempfile_path = tmpdir.join(title + ".zip.incomplete")
  
      # Download normally
      product_info = api.download(uuid, str(tmpdir), checksum=True)
      assert expected_path.samefile(product_info["path"])
      assert not tempfile_path.check(exists=1)
      assert product_info["title"] == title
      assert product_info["size"] == expected_path.size()
      assert product_info["downloaded_bytes"] == expected_path.size()
  
      hash = expected_path.computehash("md5")
      modification_time = expected_path.mtime()
      expected_product_info = product_info
  
      # File exists, expect nothing to happen
      product_info = api.download(uuid, str(tmpdir))
      assert not tempfile_path.check(exists=1)
      assert expected_path.mtime() == modification_time
      expected_product_info["downloaded_bytes"] = 0
      assert product_info == expected_product_info
  
      # Create invalid but full-sized tempfile, expect re-download
      expected_path.move(tempfile_path)
      with tempfile_path.open("wb") as f:
          f.seek(expected_product_info["size"] - 1)
          f.write(b"\0")
      assert tempfile_path.computehash("md5") != hash
      product_info = api.download(uuid, str(tmpdir))
      assert expected_path.check(exists=1, file=1)
      assert expected_path.computehash("md5") == hash
      expected_product_info["downloaded_bytes"] = expected_product_info[
          "size"
      ]
      assert product_info == expected_product_info
  
      # Create invalid tempfile, without checksum check
      # Expect continued download and no exception
      dummy_content = b"aaaaaaaaaaaaaaaaaaaaaaaaa"
      with tempfile_path.open("wb") as f:
          f.write(dummy_content)
      expected_path.remove()
      product_info = api.download(uuid, str(tmpdir), checksum=False)
      assert not tempfile_path.check(exists=1)
      assert expected_path.check(exists=1, file=1)
      assert expected_path.computehash("md5") != hash
      expected_product_info["downloaded_bytes"] = expected_product_info[
          "size"
      ] - len(dummy_content)
      assert product_info == expected_product_info
  
      # Create invalid tempfile, with checksum check
      # Expect continued download and exception raised
      dummy_content = b"aaaaaaaaaaaaaaaaaaaaaaaaa"
      with tempfile_path.open("wb") as f:
          f.write(dummy_content)
      expected_path.remove()
      with pytest.raises(InvalidChecksumError):
          api.download(uuid, str(tmpdir), checksum=True)
      assert not tempfile_path.check(exists=1)
      assert not expected_path.check(exists=1, file=1)
  
      tmpdir.remove()
  
imports: import os
  import shutil
  import py.path
  import pytest
  import requests_mock
  from flaky import flaky
  from sentinelsat import SentinelAPI, make_path_filter
  from sentinelsat.exceptions import InvalidChecksumError, InvalidKeyError, LTAError, ServerError
label_desc: Use image node_id 5 for calling a global function with example usage: test_download(api, tmpdir, smallest_online_products) without return types