code: def test_fake_gitlab(path=None):
      from unittest.mock import patch
  
      ds = Dataset(path).create()
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _NewProjectGitLab,
      ):
          res = ds.create_sibling_gitlab(
              site="dummy", project="here", description="thisisit"
          )
          assert_result_count(res, 2)
          # GitLab success
          assert_result_count(
              res,
              1,
              action="create_sibling_gitlab",
              path=path,
              type="dataset",
              site="dummy",
              sibling="dummy",
              project="here/project",
              description="thisisit",
              project_attributes={
                  "http_url_to_repo": "http://example.com",
                  "ssh_url_to_repo": "example.com",
                  "description": "thisisit",
              },
              status="ok",
          )
          assert_result_count(
              res,
              1,
              action="configure-sibling",
              path=path,
              name="dummy",
              url="http://example.com",
              status="ok",
          )
  
      # test sibling name conflicts
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _ExistingProjectGitLab,
      ):
          res = ds.create_sibling_gitlab(
              path=ds.path,
              site="dummy",
              project="here",
              existing="skip",
          )
          assert_result_count(res, 1)
          assert_result_count(
              res,
              0,
              action="create_sibling_gitlab",
              message=[
                  'already has a configured sibling "%s"',
                  "dummy",
              ],
              path=path,
              refds=path,
              site="dummy",
              sibling="dummy",
              status="notneeded",
              type="dataset",
          )
      # sibling name conflict with existing='error' should yiel error
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _ExistingProjectGitLab,
      ):
          res = ds.create_sibling_gitlab(
              path=ds.path,
              site="dummy",
              project="here",
              existing="skip",
          )
          assert_result_count(res, 1)
          assert_result_count(
              res,
              0,
              action="create_sibling_gitlab",
              message=[
                  'already has a configured sibling "%s"',
                  "dummy",
              ],
              path=path,
              refds=path,
              site="dummy",
              sibling="dummy",
              status="error",
              type="dataset",
          )
      # try recreation, the sibling is already configured, same setup, no error
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _ExistingProjectGitLab,
      ):
          res = ds.create_sibling_gitlab(
              path=ds.path,
              site="dummy",
              project="here",
              existing="reconfigure",
          )
          assert_result_count(
              res,
              1,
              action="configure-sibling",
              path=path,
              name="dummy",
              url="http://example.com",
              status="ok",
          )
          # but error when the name differs
          res = ds.create_sibling_gitlab(
              site="dummy",
              project="here",
              name="othername",
              on_failure="ignore",
          )
          assert_result_count(res, 1)
          assert_result_count(
              res,
              1,
              action="create_sibling_gitlab",
              path=path,
              site="dummy",
              sibling="othername",
              project="here/project",
              project_attributes={
                  "http_url_to_repo": "http://example.com",
                  "ssh_url_to_repo": "example.com",
              },
              status="error",
          )
  
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _CreateFailureGitLab,
      ):
          assert_status(
              "error",
              ds.create_sibling_gitlab(
                  site="dummy", project="here", on_failure="ignore"
              ),
          )
  
      # new sibling, ssh access
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _NewProjectGitLab,
      ):
          res = ds.create_sibling_gitlab(
              site="sshsite", project="here", access="ssh"
          )
          assert_result_count(res, 2)
          assert_result_count(
              res,
              1,
              action="create_sibling_gitlab",
              path=path,
              type="dataset",
              site="sshsite",
              sibling="sshsite",
              project="here/project",
              project_attributes={
                  "http_url_to_repo": "http://example.com",
                  "ssh_url_to_repo": "example.com",
                  "description": None,
              },
              status="ok",
          )
          assert_result_count(
              res,
              1,
              action="configure-sibling",
              path=path,
              name="sshsite",
              url="example.com",
              status="ok",
          )
  
      with patch(
          "datalad.distributed.create_sibling_gitlab.GitLabSite",
          _ExistingProjectOtherURLGitLab,
      ):
          res = ds.create_sibling_gitlab(
              site="sshsite",
              project="here",
              access="ssh",
              on_failure="ignore",
              name="sshsite2",
          )
          assert_result_count(res, 1)
          assert_result_count(
              res,
              0,
              action="create_sibling_gitlab",
              message=[
                  "There is already a project at '%s' on site '%s', "
                  "but no sibling with name '%s' is configured, "
                  "maybe use --existing=reconfigure",
                  "here",
                  "sshsite",
                  "sshsite2",
              ],
              path=path,
              refds=path,
              site="sshsite",
              sibling="sshsite2",
              project="here/project",
              project_attributes={
                  "http_url_to_repo": "http://example2.com",
                  "ssh_url_to_repo": "example2.com",
              },
              status="error",
              type="dataset",
          )
          # same goes for switching the access type without --reconfigure
          assert_status(
              "error",
              ds.create_sibling_gitlab(
                  site="sshsite",
                  project="here",
                  access="http",
                  on_failure="ignore",
              ),
          )
  
imports: import os
  import pytest
  from datalad.api import Dataset, create, create_sibling_gitlab
  from datalad.tests.utils_pytest import assert_raises, assert_repo_status, assert_result_count, assert_status, eq_, with_tempfile
  from datalad.utils import chpwd
label_desc: Use image node_id 3 for calling a global function with example usage: test_fake_gitlab(path) without return types