Example #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.addEntity(Game, 10, {'title': title_fake})
        self.assertEqual(len(populator.execute()[Game]), title_fake.count)
Example #2
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)
Example #3
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)
Example #4
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)
Example #5
0
    def testPopulation(self):

        generator = fake
        populator = Populator(generator)
        populator.addEntity(Game, 10)
        self.assertEqual(len(populator.execute()[Game]), 10)
Example #6
0
    def testPopulation(self):

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