class_docstr: Checks all functions of the FileCodeDriver
class_docstr_tok: ["Checks","all","functions","of","the","FileCodeDriver"]
code: def test_checkout_ref(self):
      # Test failure, not initialized
      failed = False
      try:
          self.file_code_driver.create_ref()
      except CodeNotInitialized:
          failed = True
      assert failed
      self.__setup()
      commit_hash = "69a329523ce1ec88bf63061863d9cb14"
      # Test trying to checkout failure (commit does not exist)
      failed = False
      try:
          self.file_code_driver.checkout_ref(commit_id=commit_hash)
      except FileIOError:
          failed = True
      assert failed
      # Test successful checkout (same commit as current, no changes)
      commit_hash = self.file_code_driver.create_ref()
      result = self.file_code_driver.checkout_ref(commit_id=commit_hash)
      assert result
      # Test trying to checkout failure (unstaged changes)
      with open(os.path.join(self.temp_dir, "test2.txt"), "wb") as f:
          f.write(to_bytes("hello"))
      failed = False
      try:
          self.file_code_driver.checkout_ref(commit_id=commit_hash)
      except UnstagedChanges:
          failed = True
      assert failed
      # Test successful checkout with new commit (files back to old commit)
      _ = self.file_code_driver.create_ref()
      result = self.file_code_driver.checkout_ref(commit_id=commit_hash)
      assert result
      commit_filepath = os.path.join(
          self.file_code_driver._code_filepath, commit_hash
      )
      # Check all files in commit file exist and are at the correct point
      with open(commit_filepath, "r") as f:
          for line in f:
              tracked_filepath, filehash = line.rstrip().split(",")
              destination_absolute_filepath = os.path.join(
                  self.file_code_driver.root, tracked_filepath
              )
              assert os.path.isfile(destination_absolute_filepath)
              assert filehash == self.file_code_driver._get_filehash(
                  destination_absolute_filepath
              )
      # Check that files in the latest commit are not present
      assert not os.path.isfile(
          os.path.join(self.temp_dir, "test2.txt")
      )
  
imports: from __future__ import division
  from __future__ import unicode_literals
  import os
  import time
  import shutil
  import tempfile
  import platform
  from io import open
  from datmo.core.controller.code.driver.file import FileCodeDriver
  from datmo.core.util.exceptions import PathDoesNotExist, FileIOError, CodeNotInitialized, UnstagedChanges, CommitDoesNotExist
label_desc: Use image node_id 19 for calling the TestFileCodeDriver obj's underlying member method code with example usage: obj.test_checkout_ref() without return types