code: def test_safetynet(otherpath=None, origpath=None, clonepath=None):
      # we start with a dataset that is hosted somewhere
      origds = Dataset(origpath).create()
      # a clone is made to work on the dataset
      cloneds = clone(origds, clonepath)
      # checkout a different branch at origin to simplify testing below
      origds.repo.call_git(["checkout", "-b", "otherbranch"])
  
      # an untracked file is added to simulate some work
      (cloneds.pathobj / "file1").write_text("some text")
      # now we try to drop the entire dataset in a variety of ways
      # to check that it does not happen too quickly
  
      # cannot use invalid mode switch values
      assert_raises(ValueError, drop, what="bananas")
      assert_raises(ValueError, drop, reckless="rubberducky")
  
      # cannot simple run drop somewhere and give a path to a dataset
      # to drop
      with chpwd(otherpath):
          assert_raises(NoDatasetFound, drop, clonepath, what="all")
      ok_(cloneds.is_installed())
  
      # refuse to remove the CWD
      with chpwd(clonepath):
          assert_raises(RuntimeError, drop, what="all")
      ok_(cloneds.is_installed())
  
      assert_in_results(
          cloneds.drop(what="all", on_failure="ignore"),
          message="cannot drop untracked content, save first",
          status="impossible",
      )
      ok_(cloneds.is_installed())
  
      # so let's save...
      cloneds.save()
      # - branch is progressed
      # - a new key is only available here
      res = cloneds.drop(what="all", on_failure="ignore")
      assert_in_results(res, action="uninstall", status="error")
      ok_(
          res[0]["message"][0].startswith(
              "to-be-dropped dataset has revisions "
              "that are not available at any known sibling"
          )
      )
      ok_(cloneds.is_installed())
  
      # so let's push -- git only
      # we cannot use git-push directly, it would not handle
      # managed branches properly
      cloneds.push(data="nothing")
  
      res = cloneds.drop(what="all", on_failure="ignore")
      assert_in_results(res, action="uninstall", status="error")
      ok_(
          res[0]["message"][0].startswith(
              "to-be-deleted local annex not declared 'dead'"
          )
      )
      # some windows test setup is not very robust, explicitly
      # include the default name "origin" in the test success
      # conditions to make this more robust
      eq_(res[0]["message"][1], [DEFAULT_REMOTE])
      ok_(cloneds.is_installed())
  
      # announce dead
      cloneds.repo.call_annex(["dead", "here"])
      # but just a local declaration is not good enough
      assert_in_results(
          cloneds.drop(what="all", on_failure="ignore"), status="error"
      )
      ok_(cloneds.is_installed())
  
      # so let's push that announcement also
      cloneds.push(data="nothing")
  
      res = cloneds.drop(what="all", on_failure="ignore")
      assert_in_results(res, action="drop", status="error")
      ok_(
          res[0]["message"].startswith("unsafe\nCould"),
          msg=f"Results were {res}",
      )
      ok_(cloneds.is_installed())
  
      # so let's push all
      cloneds.push()
  
      # and kill the beast!
      res = cloneds.drop(what="all", on_failure="ignore")
      # only now we also drop the key!
      assert_result_count(res, 2)
      assert_in_results(
          res, action="drop", type="key", status="ok", path=cloneds.path
      )
      assert_in_results(
          res,
          action="uninstall",
          type="dataset",
          status="ok",
          path=cloneds.path,
      )
  
imports: import os
  import os.path
  from pathlib import Path
  from unittest.mock import patch
  from datalad.api import Dataset, clone, create, drop
  from datalad.distributed.drop import _detect_nondead_annex_at_remotes, _detect_unpushed_revs
  from datalad.support.exceptions import IncompleteResultsError, NoDatasetFound
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, OBSCURE_FILENAME, assert_in, assert_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, eq_, get_deeply_nested_structure, known_failure_githubci_win, nok_, ok_, with_tempfile
  from datalad.utils import chpwd
label_desc: Use image node_id 6 for calling a global function with example usage: test_safetynet(otherpath, origpath, clonepath) without return types