def authors(self, create, extracted, **kwargs): if not create: return if extracted: for author in extracted: self.authors.add(author) return for x in range(random.randint(1, 4)): if x == 0: author = ProfileFactory.create(**kwargs) else: author = ProfileFactory.create() self.authors.add(author)
def test_profile(self): ProfileFactory.create_batch(size=10) test_profile = ProfileFactory.create(first_name='Peter', last_name='File', is_active=True, homepage='http://www.test.com', affiliation='Reynholm Industries') self.assertTrue(isinstance(test_profile, Profile)) self.assertEqual(test_profile.first_name, 'Peter') self.assertEqual(test_profile.last_name, 'File') self.assertTrue(test_profile.is_active) self.assertTrue(test_profile.check_password('password')) self.assertEqual(test_profile.homepage, 'http://www.test.com') self.assertEqual(test_profile.affiliation, 'Reynholm Industries')