docstr: Method:
  1. return error if create partition when partition key is on
  2. return error if insert partition when partition key is on
  3. return error if drop partition when partition key is on
  4. return success if show partition when partition key is on
  5. return error if load partition when partition key is on
  6. return error if release partition when partition key is on
  Expected: raise exception
docstr_tok: ["Method",":","1.","return","error","if","create","partition","when","partition","key","is","on","2.","return","error","if","insert","partition","when","partition","key","is","on","3.","return","error","if","drop","partition","when","partition","key","is","on","4.","return","success","if","show","partition","when","partition","key","is","on","5.","return","error","if","load","partition","when","partition","key","is","on","6.","return","error","if","release","partition","when","partition","key","is","on","Expected",":","raise","exception"]
code: def test_create_partition(self):
      """
      Method:
      1. return error if create partition when partition key is on
      2. return error if insert partition when partition key is on
      3. return error if drop partition when partition key is on
      4. return success if show partition when partition key is on
      5. return error if load partition when partition key is on
      6. return error if release partition when partition key is on
      Expected: raise exception
      """
      self._connect()
      pk_field = cf.gen_int64_field(name="pk", is_primary=True)
      int64_field = cf.gen_int64_field()
      string_field = cf.gen_string_field(is_partition_key=True)
      vector_field = cf.gen_float_vec_field()
      schema = cf.gen_collection_schema(
          fields=[pk_field, int64_field, string_field, vector_field],
          auto_id=True,
      )
      c_name = cf.gen_unique_str("par_key")
      collection_w, _ = self.collection_wrap.init_collection(
          name=c_name, schema=schema
      )
  
      # create partition
      err_msg = "disable create partition if partition key mode is used"
      partition_name = cf.gen_unique_str("partition")
      self.collection_wrap.create_partition(
          partition_name,
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      self.partition_wrap.init_partition(
          collection_w,
          partition_name,
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
  
      # get partition is allowed
      partitions = self.collection_wrap.partitions
      collection_w.partition(partitions[0].name)
      self.partition_wrap.init_partition(
          collection_w, partitions[0].name
      )
      assert self.partition_wrap.name == partitions[0].name
      # has partition is allowed
      assert collection_w.has_partition(partitions[0].name)
      assert self.utility_wrap.has_partition(
          collection_w.name, partitions[0].name
      )
  
      # insert
      nb = 100
      string_prefix = cf.gen_str_by_length(length=6)
      entities_per_parkey = 10
      for _ in range(entities_per_parkey):
          int64_values = [i for i in range(0, nb)]
          string_values = [string_prefix + str(i) for i in range(0, nb)]
          float_vec_values = gen_vectors(nb, ct.default_dim)
          data = [int64_values, string_values, float_vec_values]
          self.collection_wrap.insert(data)
  
      err_msg = "not support manually specifying the partition names if partition key mode is used"
      self.partition_wrap.insert(
          data,
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      self.collection_wrap.insert(
          data,
          partition_name=partitions[0].name,
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
  
      err_msg = "disable load partitions if partition key mode is used"
      self.partition_wrap.load(
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      self.collection_wrap.load(
          partition_names=[partitions[0].name],
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
  
      # flush
      collection_w.flush()
  
      # build index
      collection_w.create_index(
          field_name=vector_field.name, index_params=ct.default_index
      )
      # load
      collection_w.load()
      # search
      nq = 10
      search_vectors = gen_vectors(nq, ct.default_dim)
      # search with mixed filtered
      res1 = self.collection_wrap.search(
          data=search_vectors,
          anns_field=vector_field.name,
          param=ct.default_search_params,
          limit=entities_per_parkey,
          expr=f'{int64_field.name} in [1,3,5] && {string_field.name} in ["{string_prefix}1","{string_prefix}3","{string_prefix}5"]',
          output_fields=[int64_field.name, string_field.name],
          check_task=CheckTasks.check_search_results,
          check_items={"nq": nq, "limit": ct.default_limit},
      )[0]
      pks = res1[0].ids[:3]
      err_msg = "not support manually specifying the partition names if partition key mode is used"
      self.collection_wrap.search(
          data=search_vectors,
          anns_field=vector_field.name,
          partition_names=[partitions[0].name],
          param=ct.default_search_params,
          limit=entities_per_parkey,
          expr=f"{int64_field.name} in [1,3,5]",
          output_fields=[int64_field.name, string_field.name],
          check_task=CheckTasks.err_res,
          check_items={"err_code": nq, "err_msg": err_msg},
      )
      self.partition_wrap.search(
          data=search_vectors,
          anns_field=vector_field.name,
          params=ct.default_search_params,
          limit=entities_per_parkey,
          expr=f'{string_field.name} in ["{string_prefix}1","{string_prefix}3","{string_prefix}5"]',
          output_fields=[int64_field.name, string_field.name],
          check_task=CheckTasks.err_res,
          check_items={"err_code": nq, "err_msg": err_msg},
      )
  
      # partition loading progress is allowed
      self.utility_wrap.loading_progress(
          collection_name=collection_w.name
      )
      self.utility_wrap.loading_progress(
          collection_name=collection_w.name,
          partition_names=[partitions[0].name],
      )
  
      # partition wait for loading complete is allowed
      self.utility_wrap.wait_for_loading_complete(
          collection_name=collection_w.name
      )
      self.utility_wrap.wait_for_loading_complete(
          collection_name=collection_w.name,
          partition_names=[partitions[0].name],
      )
      # partition flush is allowed: #24165
      self.partition_wrap.flush()
  
      # partition delete is not allowed
      self.partition_wrap.delete(
          expr=f"{pk_field.name} in {pks}",
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      self.collection_wrap.delete(
          expr=f"{pk_field.name} in {pks}",
          partition_name=partitions[0].name,
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      # partition query is not allowed
      self.partition_wrap.query(
          expr=f"{pk_field.name} in {pks}",
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      self.collection_wrap.query(
          expr=f"{pk_field.name} in {pks}",
          partition_names=[partitions[0].name],
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      # partition upsert is not allowed
      # self.partition_wrap.upsert(data=data, check_task=CheckTasks.err_res,
      #                            check_items={"err_code": 2, "err_msg": err_msg})
      # self.collection_wrap.upsert(data=data, partition_name=partitions[0].name,
      #                             chek_task=CheckTasks.err_res, check_items={"err_code": 2, "err_msg": err_msg})
      # partition release
      err_msg = (
          "disable release partitions if partition key mode is used"
      )
      self.partition_wrap.release(
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
      # partition drop
      err_msg = "disable drop partition if partition key mode is used"
      self.partition_wrap.drop(
          check_task=CheckTasks.err_res,
          check_items={"err_code": 2, "err_msg": err_msg},
      )
  
imports: import pytest
  from base.client_base import TestcaseBase
  from common import common_func
  from common import common_type
  from common.common_type import CaseLabel, CheckTasks
  from utils.util_pymilvus import *
label_desc: Use image node_id 1 for calling the TestPartitionApiForbidden obj's underlying member method code with example usage: obj.test_create_partition() without return types