code: def test_download_file_class(self):
      # Test normal scenario
      resource = download.DownloadableFile(
          TEST_DOWNLOAD_URL,
          "visual_entailment_small.zip",
          hashcode=TEST_DOWNLOAD_SHASUM,
          compressed=True,
      )
  
      with tempfile.TemporaryDirectory() as d:
          with contextlib.redirect_stdout(StringIO()):
              resource.download_file(d)
          self.assertTrue(
              os.path.exists(os.path.join(d, "visual_entailment_small"))
          )
          self.assertTrue(
              os.path.exists(
                  os.path.join(
                      d, "visual_entailment_small", "db", "train.jsonl"
                  )
              )
          )
          self.assertTrue(
              os.path.exists(
                  os.path.join(
                      d,
                      "visual_entailment_small",
                      "features",
                      "features.lmdb",
                      "data.mdb",
                  )
              )
          )
          self.assertTrue(
              os.path.exists(
                  os.path.join(d, "visual_entailment_small.zip")
              )
          )
  
      # Test when checksum fails
      resource = download.DownloadableFile(
          TEST_DOWNLOAD_URL,
          "visual_entailment_small.zip",
          hashcode="some_random_string",
          compressed=True,
      )
  
      with tempfile.TemporaryDirectory() as d:
          with contextlib.redirect_stdout(StringIO()):
              self.assertRaises(
                  AssertionError, resource.download_file, d
              )
  
      # Test when not compressed
      resource = download.DownloadableFile(
          TEST_DOWNLOAD_URL,
          "visual_entailment_small.zip",
          hashcode=TEST_DOWNLOAD_SHASUM,
          compressed=False,
      )
  
      with tempfile.TemporaryDirectory() as d:
          with contextlib.redirect_stdout(StringIO()):
              resource.download_file(d)
          self.assertTrue(
              os.path.exists(
                  os.path.join(d, "visual_entailment_small.zip")
              )
          )
          # Check already downloaded scenarios
  
          with mock.patch.object(resource, "checksum") as mocked:
              with contextlib.redirect_stdout(StringIO()):
                  resource.download_file(d)
              mocked.assert_called_once_with(d)
  
          with mock.patch("mmf.utils.download.download") as mocked:
              with contextlib.redirect_stdout(StringIO()):
                  resource.download_file(d)
              mocked.assert_called_once_with(
                  resource._url,
                  d,
                  resource._file_name,
                  redownload=False,
              )
          with mock.patch.object(resource, "checksum") as mocked:
              resource._hashcode = "some_random_string"
              with contextlib.redirect_stdout(StringIO()):
                  resource.download_file(d)
              self.assertTrue(mocked.call_count, 2)
  
          with mock.patch("mmf.utils.download.download") as mocked:
              resource._hashcode = "some_random_string"
              with contextlib.redirect_stdout(StringIO()):
                  self.assertRaises(
                      AssertionError, resource.download_file, d
                  )
              mocked.assert_called_once_with(
                  resource._url, d, resource._file_name, redownload=True
              )
  
      # Test delete original
      resource = download.DownloadableFile(
          TEST_DOWNLOAD_URL,
          "visual_entailment_small.zip",
          hashcode=TEST_DOWNLOAD_SHASUM,
          compressed=True,
          delete_original=True,
      )
  
      with tempfile.TemporaryDirectory() as d:
          with contextlib.redirect_stdout(StringIO()):
              resource.download_file(d)
          self.assertFalse(
              os.path.exists(
                  os.path.join(d, "visual_entailment_small.zip")
              )
          )
  
file_path: mmf/tests/utils/test_download.py
imports: import contextlib
  import os
  import tempfile
  import unittest
  from io import StringIO
  from unittest import mock
  import mmf.utils.download
  import tests.test_utils
label_desc: Use image node_id 1 for calling the TestUtilsDownload obj's underlying member method code with example usage: obj.test_download_file_class() without return types