Creates a test model state and database table.
(
self,
app_label,
second_model=False,
third_model=False,
index=False,
multicol_index=False,
related_model=False,
mti_model=False,
proxy_model=False,
manager_model=False,
unique_together=False,
options=False,
db_table=None,
constraints=None,
indexes=None,
)
| 272 | return project_state, new_state |
| 273 | |
| 274 | def set_up_test_model( |
| 275 | self, |
| 276 | app_label, |
| 277 | second_model=False, |
| 278 | third_model=False, |
| 279 | index=False, |
| 280 | multicol_index=False, |
| 281 | related_model=False, |
| 282 | mti_model=False, |
| 283 | proxy_model=False, |
| 284 | manager_model=False, |
| 285 | unique_together=False, |
| 286 | options=False, |
| 287 | db_table=None, |
| 288 | constraints=None, |
| 289 | indexes=None, |
| 290 | ): |
| 291 | """Creates a test model state and database table.""" |
| 292 | # Make the "current" state. |
| 293 | model_options = {"swappable": "TEST_SWAP_MODEL"} |
| 294 | if options: |
| 295 | model_options["permissions"] = [("can_groom", "Can groom")] |
| 296 | if db_table: |
| 297 | model_options["db_table"] = db_table |
| 298 | if unique_together: |
| 299 | model_options["unique_together"] = {("pink", "weight")} |
| 300 | operations = [ |
| 301 | migrations.CreateModel( |
| 302 | "Pony", |
| 303 | [ |
| 304 | ("id", models.AutoField(primary_key=True)), |
| 305 | ("pink", models.IntegerField(default=3)), |
| 306 | ("weight", models.FloatField()), |
| 307 | ("green", models.IntegerField(null=True)), |
| 308 | ( |
| 309 | "yellow", |
| 310 | models.CharField( |
| 311 | blank=True, null=True, db_default="Yellow", max_length=20 |
| 312 | ), |
| 313 | ), |
| 314 | ], |
| 315 | options=model_options, |
| 316 | ) |
| 317 | ] |
| 318 | if index: |
| 319 | operations.append( |
| 320 | migrations.AddIndex( |
| 321 | "Pony", |
| 322 | models.Index(fields=["pink"], name="pony_pink_idx"), |
| 323 | ) |
| 324 | ) |
| 325 | if multicol_index: |
| 326 | operations.append( |
| 327 | migrations.AddIndex( |
| 328 | "Pony", |
| 329 | models.Index(fields=["pink", "weight"], name="pony_test_idx"), |
| 330 | ) |
| 331 | ) |
no test coverage detected