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.addEntity(Game, 10, {'title': title_fake}) self.assertEqual(len(populator.execute()[Game]), title_fake.count)
def testFormatter(self): generator = fake populator = Populator(generator) populator.addEntity(Game, 5) populator.addEntity( Player, 10, { 'score': lambda x: fake.randomInt(0, 1000), 'nickname': lambda x: fake.email() }) populator.addEntity(Action, 30) populator.addEntity(ModelWithCustomField, 10, {'custom_field': generator.city()}) 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() ])) self.assertTrue(len(insertedPks[ModelWithCustomField]) == 10)
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.addEntity( Game, 10, { 'title': title_fake } ) self.assertEqual(len(populator.execute()[Game]), title_fake.count)
def testFormatter(self): generator = fake populator = Populator( generator ) populator.addEntity(Game,5) populator.addEntity(Player, 10, { 'score': lambda x: fake.randomInt(0,1000), 'nickname': lambda x: fake.email() }) populator.addEntity(Action,30) populator.addEntity(ModelWithCustomField, 10, { 'custom_field': generator.city() }) 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() ]) ) self.assertTrue( len(insertedPks[ModelWithCustomField]) == 10)
def testPopulation(self): generator = fake populator = Populator(generator) populator.addEntity(Game, 10) self.assertEqual(len(populator.execute()[Game]), 10)
def testPopulation(self): generator = fake populator = Populator(generator) populator.addEntity( Game, 10 ) self.assertEqual(len(populator.execute()[Game]), 10)