code: def test_post_messages_in_private_or_gated_dataset(
      job_config: JobConfig, gated: bool, private: bool
  ) -> None:
      with TemporaryDataset(
          prefix="dataset", gated=gated, private=private
      ) as dataset:
          assert fetch_bot_discussion(dataset=dataset.repo_id) is None
          # set "config-parquet" entry for the dataset
          upsert_response(
              kind=PARQUET_CACHE_KIND,
              dataset=dataset.repo_id,
              dataset_git_revision=REVISION_NAME,
              content={},
              http_status=HTTPStatus.OK,
          )
          # call post_messages
          counters = post_messages(
              hf_endpoint=job_config.common.hf_endpoint,
              bot_associated_user_name=job_config.discussions.bot_associated_user_name,
              bot_token=job_config.discussions.bot_token,
              parquet_revision=job_config.discussions.parquet_revision,
          )
          # ensure one discussion has been created
          # YES: even if it's private. Should we forbid this?
          # Normally: the cache should not contain private datasets, but a public
          # dataset can be switched to private, and for some reason, or during some
          # time, the cache can contain private datasets.
          assert counters["parquet"] == {
              "datasets": 1,
              "new_discussions": 1,
              "dismissed_discussions": 0,
              "errors": 0,
          }
          first_discussion = fetch_bot_discussion(
              dataset=dataset.repo_id
          )
          assert first_discussion is not None
          assert count_comments(first_discussion) == 1
          comment = first_discussion.events[0]
          assert isinstance(comment, DiscussionComment)
          assert comment.content == create_discussion_description(
              dataset=dataset.repo_id,
              hf_endpoint=job_config.common.hf_endpoint,
              parquet_revision=job_config.discussions.parquet_revision,
              bot_associated_user_name=job_config.discussions.bot_associated_user_name
              or DEFAULT_BOT_NAME,
          )
  
file_path: datasets-server/jobs/cache_maintenance/tests/test_discussions.py
imports: from http import HTTPStatus
  import pytest
  from huggingface_hub.community import DiscussionComment
  from libcommon.simple_cache import upsert_response
  from libcommon.utils import get_datetime
  from cache_maintenance.config import JobConfig
  from cache_maintenance.discussions import DAYS, PARQUET_CACHE_KIND, create_discussion_description, create_link, limit_to_one_dataset_per_namespace, post_messages
  from .utils import REVISION_NAME, TemporaryDataset, close_discussion, count_comments, fetch_bot_discussion
label_desc: Use image node_id 5 for calling a global function with example usage: test_post_messages_in_private_or_gated_dataset(job_config, gated, private) without return types