async def test_bulk_create_uuidpk_in_transaction(self): async with in_transaction(): await UUIDPkModel.bulk_create([UUIDPkModel() for _ in range(1000)]) res = await UUIDPkModel.all().values_list("id", flat=True) self.assertEqual(len(res), 1000) self.assertIsInstance(res[0], UUID)
async def test_bulk_create_uuidpk_in_transaction_fail(self): val = uuid4() with self.assertRaises(IntegrityError): async with in_transaction(): await UUIDPkModel.bulk_create([UUIDPkModel(id=val) for _ in range(10)])
async def test_describe_model_uuidpk_native(self): val = UUIDPkModel.describe(serializable=False) self.assertEqual( val, { "name": "models.UUIDPkModel", "app_label": "models", "db_table": "models_uuidpkmodel", "abstract": False, "description": None, "unique_together": [], "pk_field": { "name": "id", "field_type": fields.UUIDField, "db_column": "id", "db_column_types": { "": "CHAR(36)", "postgres": "UUID" }, "python_type": uuid.UUID, "generated": False, "auto_created": False, "nullable": False, "unique": True, "db_index": True, "default": uuid.uuid4, "description": None, }, "fields": [ { "name": "children", "field_type": BackwardFKField, "python_type": UUIDFkRelatedModel, "generated": False, "auto_created": True, "nullable": True, "unique": False, "db_index": False, "default": None, "description": None, }, { "name": "peers", "field_type": ManyToManyField, "python_type": UUIDM2MRelatedModel, "generated": False, "auto_created": True, "nullable": False, "unique": False, "db_index": False, "default": None, "description": None, }, ], }, )