Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def testPopulationErrors(self):
        generator = fake
        populator = Populator(generator)

        self.assertRaises(AttributeError, populator.addEntity,
                          ModelWithCustomField, 10)
        self.assertRaises(AttributeError, populator.execute)
Ejemplo n.º 4
0
    def testFormatter(self):

        generator = fake

        populator = Populator( generator )

        populator.addEntity(Game,5)
        populator.addEntity(Player, 10, {
            'score': lambda x: fake.random_int(0,1000),
            'nickname': lambda x: fake.email()
        })
        populator.addEntity(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() ]) )
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    def testPopulation(self):

        generator = fake
        populator = Populator(generator)
        populator.addEntity(Game, 10)
        self.assertEqual(len(populator.execute()[Game]), 10)
Ejemplo n.º 7
0
    def testPopulation(self):

        generator = fake
        populator = Populator(generator)
        populator.addEntity( Game, 10 )
        self.assertEqual(len(populator.execute()[Game]), 10)