Exemplo n.º 1
0
def populate():
    ProfileFactory.create_batch(size=10)
    PostFactory.create_batch(size=4)
    PostImageFactory.create_batch(size=16)
    PaperFactory.create_batch(size=10)

    for p in Post.objects.all():
        print(p)
    print("...population finished")
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
 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)