(self)
| 531 | management.call_command("loaddata", file, verbosity=0) |
| 532 | |
| 533 | def test_dumpdata_with_excludes(self): |
| 534 | # Load fixture1 which has a site, two articles, and a category |
| 535 | Site.objects.all().delete() |
| 536 | management.call_command("loaddata", "fixture1.json", verbosity=0) |
| 537 | |
| 538 | # Excluding fixtures app should only leave sites |
| 539 | self._dumpdata_assert( |
| 540 | ["sites", "fixtures"], |
| 541 | '[{"pk": 1, "model": "sites.site", "fields": ' |
| 542 | '{"domain": "example.com", "name": "example.com"}}]', |
| 543 | exclude_list=["fixtures"], |
| 544 | ) |
| 545 | |
| 546 | # Excluding fixtures.Article/Book should leave fixtures.Category |
| 547 | self._dumpdata_assert( |
| 548 | ["sites", "fixtures"], |
| 549 | '[{"pk": 1, "model": "sites.site", ' |
| 550 | '"fields": {"domain": "example.com", "name": "example.com"}}, ' |
| 551 | '{"pk": 1, "model": "fixtures.category", "fields": ' |
| 552 | '{"description": "Latest news stories", "title": "News Stories"}}]', |
| 553 | exclude_list=["fixtures.Article", "fixtures.Book"], |
| 554 | ) |
| 555 | |
| 556 | # Excluding fixtures and fixtures.Article/Book should be a no-op |
| 557 | self._dumpdata_assert( |
| 558 | ["sites", "fixtures"], |
| 559 | '[{"pk": 1, "model": "sites.site", ' |
| 560 | '"fields": {"domain": "example.com", "name": "example.com"}}, ' |
| 561 | '{"pk": 1, "model": "fixtures.category", ' |
| 562 | '"fields": {"description": "Latest news stories", ' |
| 563 | '"title": "News Stories"}}]', |
| 564 | exclude_list=["fixtures.Article", "fixtures.Book"], |
| 565 | ) |
| 566 | |
| 567 | # Excluding sites and fixtures.Article/Book should only leave |
| 568 | # fixtures.Category |
| 569 | self._dumpdata_assert( |
| 570 | ["sites", "fixtures"], |
| 571 | '[{"pk": 1, "model": "fixtures.category", "fields": ' |
| 572 | '{"description": "Latest news stories", "title": "News Stories"}}]', |
| 573 | exclude_list=["fixtures.Article", "fixtures.Book", "sites"], |
| 574 | ) |
| 575 | |
| 576 | # Excluding a bogus app should throw an error |
| 577 | with self.assertRaisesMessage( |
| 578 | management.CommandError, "No installed app with label 'foo_app'." |
| 579 | ): |
| 580 | self._dumpdata_assert(["fixtures", "sites"], "", exclude_list=["foo_app"]) |
| 581 | |
| 582 | # Excluding a bogus model should throw an error |
| 583 | with self.assertRaisesMessage( |
| 584 | management.CommandError, "Unknown model: fixtures.FooModel" |
| 585 | ): |
| 586 | self._dumpdata_assert( |
| 587 | ["fixtures", "sites"], "", exclude_list=["fixtures.FooModel"] |
| 588 | ) |
| 589 | |
| 590 | @unittest.skipIf( |
nothing calls this directly
no test coverage detected