def testGuesser(self): generator = fake def title_fake(arg): title_fake.count += 1 name = generator.company() return name title_fake.count = 0 populator = Populator(generator) populator.add_entity(Game, 10, {'title': title_fake}) self.assertEqual(len(populator.execute()[Game]), title_fake.count)
def testFormatter(self): generator = fake populator = Populator(generator) populator.add_entity(Game, 5) populator.add_entity( Player, 10, { 'score': lambda x: fake.random_int(0, 1000), 'nickname': lambda x: fake.email() }) populator.add_entity(Action, 30) insertedPks = populator.execute() self.assertTrue(len(insertedPks[Game]) == 5) self.assertTrue(len(insertedPks[Player]) == 10) self.assertTrue( any([ 0 <= p.score <= 1000 and '@' in p.nickname for p in Player.objects.all() ]))
def testPopulation(self): generator = fake populator = Populator(generator) populator.add_entity(Game, 10) self.assertEqual(len(populator.execute()[Game]), 10)