示例#1
0
class VenueFactory(factory.DjangoModelFactory):
    class Meta:
        model = Venue

    quadra = factory.LazyAttribute(lambda o: faker.company())
    address = factory.LazyAttribute(lambda o: faker.address())
    location = Geoposition(52.522906, 13.41156)
示例#2
0
class ColaboratorFactory(DjangoModelFactory):
    class Meta:
        model = Colaborator

    name = lazy_attribute(lambda o: faker.company())
    url = lazy_attribute(lambda o: faker.url())
    active = True
示例#3
0
def init_collection_data():
    person_collection = test_db['person']

    persons = []
    for num in range(1000000):
        if num > 0 and num % 10000 == 0:
            person_collection.insert_many(persons)
            persons.clear()
            print(person_collection.count_documents({}))
        persons.append({
            'name':
            faker.name(),
            'address':
            faker.address(),
            'phone':
            faker.phone_number(),
            'postcode':
            faker.postcode(),
            'age':
            str(faker.date_of_birth(minimum_age=18, maximum_age=30)),
            'company':
            faker.company(),
            'license_plate':
            faker.license_plate()
        })

    if persons:
        person_collection.insert_many(persons)
示例#4
0
class MediaPatronFactory(DjangoModelFactory):
    class Meta:
        model = MediaPatron

    name = lazy_attribute(lambda o: faker.company())
    url = lazy_attribute(lambda o: faker.url())
    active = True
示例#5
0
class PartnerFactory(DjangoModelFactory):
    class Meta:
        model = Partner

    name = lazy_attribute(lambda o: faker.company())
    url = lazy_attribute(lambda o: faker.url())
    active = True
示例#6
0
class MediaPatronageFactory(DjangoModelFactory):
    class Meta:
        model = MediaPatronage

    @lazy_attribute
    def start(self):
        return faker.date_time_between(start_date="+20d", end_date="+30d")

    @lazy_attribute
    def end(self):
        return self.start + relativedelta(days=3)

    name = lazy_attribute(lambda o: faker.company())
    url = lazy_attribute(lambda o: faker.url())
    active = True
示例#7
0
class FormularioFactory(DjangoModelFactory):
    class Meta:
        model = Formulario

    nombre = lazy_attribute(lambda a: "ventas_{0}".format(faker.company()))
    descripcion = lazy_attribute(lambda a: faker.paragraph(10))
示例#8
0
Author.object.all().delete()

exit()

sujets = [
    'sport', 'education', 'actualités', 'evenement', 'Science',
    'art & culture', 'jeux videos', 'BD', 'politique', 'affaires'
]

fake_podcasts = []

for n in range(10):
    podcast = {}
    podcast['name'] = faker.name()
    podcast['type'] = random.choice(sujets)
    podcast['editor'] = faker.company()
    fake_podcasts.append(podcast)
    podcast['public'] = faker.domain_name()
    podcast['duration'] = random.random() * 100

for podcast in fake_podcasts:

    print('in here')
    _, created = Podcast.objects.get_or_create(name=podcast['name'],
                                               type=podcast['type'],
                                               editor=podcast['editor'],
                                               public=podcast['public'],
                                               duration=podcast['duration'])

if __name__ == '__main__':
    print("Populating the databases...Please Wait")