class_docstr: Checks all functions of the GitCodeDriver
class_docstr_tok: ["Checks","all","functions","of","the","GitCodeDriver"]
code: def test_create_ref(self):
      self.git_code_manager.init()
      # Test failing case with no code_id and nothing to commit
      failed = False
      try:
          self.git_code_manager.create_ref()
      except CommitFailed:
          failed = True
      assert failed
      # Test passing case with no code_id
      test_filepath = os.path.join(
          self.git_code_manager.filepath, "test.txt"
      )
      with open(test_filepath, "wb") as f:
          f.write(to_bytes(str("test")))
      commit_hash = self.git_code_manager.create_ref()
      code_ref_path = os.path.join(
          self.git_code_manager.filepath,
          ".git/refs/datmo/",
          commit_hash,
      )
      assert commit_hash
      assert os.path.isfile(code_ref_path)
      assert self.git_code_manager.latest_commit() == commit_hash
      # Test passing case with no code_id, new file
      test_filepath = os.path.join(
          self.git_code_manager.filepath, "test2.txt"
      )
      with open(test_filepath, "wb") as f:
          f.write(to_bytes(str("test")))
      commit_hash_2 = self.git_code_manager.create_ref()
      code_ref_path_2 = os.path.join(
          self.git_code_manager.filepath,
          ".git/refs/datmo/",
          commit_hash_2,
      )
      assert commit_hash_2
      assert commit_hash_2 != commit_hash
      assert os.path.isfile(code_ref_path_2)
      assert self.git_code_manager.latest_commit() == commit_hash_2
      # Test error raised with commit_id
      random_commit_id = str("random")
      failed = False
      try:
          self.git_code_manager.create_ref(commit_id=random_commit_id)
      except CommitDoesNotExist:
          failed = True
      assert failed
  
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.git import GitCodeDriver, GitHostDriver
  from datmo.core.util.exceptions import CommitFailed, CommitDoesNotExist, PathDoesNotExist, GitExecutionError, DatmoFolderInWorkTree, UnstagedChanges
label_desc: Use image node_id 12 for calling the TestGitCodeDriver obj's underlying member method code with example usage: obj.test_create_ref() without return types