def test_factory_can_create_many_to_many(self): with self.subTest('Can add authors to the factory'): author = factories.AuthorFactory() entry = factories.EntryFactory( authors=(author,) ) self.assertEqual(1, entry.authors.count()) with self.subTest('Traits can simplify greatly some usage'): entry = factories.EntryFactory( with_authors=True ) self.assertTrue(entry.authors.exists())
def get(self, **kwargs): return factories.AuthorFactory(**kwargs)
def author(): return factories.AuthorFactory()