コード例 #1
0
ファイル: seeders.py プロジェクト: Duckolyte/the-zebro-api
    def run(self):
        faker = Faker(
            cls=User,
            init={
                'first_name':
                generator.Name(),
                'second_name':
                generator.Name(),
                'last_name':
                generator.Name(),
                'date_of_birth':
                generators.DateTime(start_date=date_of_birth_start,
                                    end_date=date_of_birth_end),
                'user_name':
                generators.Username(user_names=random_user_names),
                'email':
                generators.Email(first_names=random_first_names,
                                 last_names=random_last_names),
                'password':
                generators.GenericListItem(generic_list=rock_solid_passwords),
                'id':
                generators.RelationalPrimaryKey(user_uuids_container)
            })

        # Create 5 users
        for user in faker.create(user_uuids_container.container_list_length()):
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #2
0
ファイル: demo.py プロジェクト: lterelak/VirtualAssistants
    def run(self):
        faker = Faker(
            cls=VirtualAssistant,
            init={
                "id":
                generator.Sequence(),
                "name":
                generator.Name(),
                "last_name":
                generator.Name(),
                "job":
                generator.String(
                    "(1st pressman|1st Pressman On Web Press|2nd Grade Teacher|2nd pressman|3d animator)"
                ),
                "image_filename":
                generator.String("[0-9]{1,2}.jpg"),
                "image_url":
                generator.String(
                    "(https://fwcdn.pl/ppo/70/74/57074/449882.2.jpg|https://fwcdn.pl/ppo/01/09/109/449960.2.jpg|https://fwcdn.pl/ppo/03/16/316/449937.2.jpg|https://ssl-gfx.filmweb.pl/ph/06/99/640699/831926_1.2.jpg|https://ssl-gfx.filmweb.pl/ph/97/46/399746/245837_1.2.jpg)"
                ),
            })

        #Create 5 virtul assistants
        for assistant in faker.create(5):
            print("Adding VirtualAssistant: %s" % assistant)
            self.db.session.add(assistant)
コード例 #3
0
class TestFaker(TestCase):
    def setUp(self):
        self.faker = Faker(cls=Dummy)

    def test_create_return_instance(self):
        result = self.faker.create()

        self.assertIsInstance(result[0], Dummy)

    def test_create_with_limit(self):
        result = self.faker.create(2)

        self.assertEqual(len(result), 2)

    def test_create_instantiate_with_init_args_value(self):
        self.faker.init = {"test_arg": "test_value"}

        result = self.faker.create()

        self.assertEqual(result[0].test_arg, "test_value")

    def test_create_run_init_args_generator(self):
        class DummyGenerator(Generator):
            def generate(self):
                return "test_value"

        self.faker.init = {"test_arg": DummyGenerator()}

        result = self.faker.create()

        self.assertEqual(result[0].test_arg, "test_value")
コード例 #4
0
ファイル: demo.py プロジェクト: stankiewiczjakub/playground
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=User,
                      init={
                          "id_num": generator.Sequence(),
                          "name": generator.Name(),
                          "age": generator.Integer(start=20, end=100)
                      })

        # Create 5 users
        for user in faker.create(5):
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #5
0
ファイル: seeders.py プロジェクト: Duckolyte/the-zebro-api
    def run(self):
        faker = Faker(
            cls=GpsPoint,
            init={
                'spotId':
                generators.RelationalForeignKey(spot_uuids_container),
                'lat': generators.GenericListItem(gps_lat_lon),
                'lon': generators.GenericListItem(gps_lat_lon),
                'id': generators.RelationalPrimaryKey(gps_uuids_container)
            })

        for gps in faker.create(gps_uuids_container.container_list_length()):
            print("Adding gps: %s" % gps)
            self.db.session.add(gps)
コード例 #6
0
    def run(self):
        name = generator.Name()
        faker = Faker(
            cls=User,
            init={
                "name": name,
                "email": ''.join(random.choice(string.ascii_letters) for i in range(10)) + '@mail.com',
                "password": "******"
            }
        )

        for user in faker.create(1):
            print("adding user: %s" % user)
            self.db.session.add(user)
コード例 #7
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=User,
                      init={
                          "id": generator.Sequence(),
                          "name": generator.Name(),
                          "email": "*****@*****.**",
                          "password": hashlib.md5("secret"),
                          "role": "admin"
                      })

        for user in faker.create(1):
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #8
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=User,
                      init={
                          "name": 'admin',
                          "username": '******',
                          "email": '*****@*****.**',
                          "password": "******"
                      })

        # Create 1 user
        for user in faker.create(1):
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #9
0
    def run(self):
        faker = Faker(cls=Actions,
                      init={
                          "id":
                          generator.Sequence(),
                          "action_name":
                          CustomFromListGenerator(
                              ["Updated post", "Updated article"]),
                      })

        for record in faker.create(2):
            print("Adding:", record)
            self.db.session.add(record)
        self.db.session.commit()
コード例 #10
0
    def run(self):
        faker = Faker(cls=Assistant,
                      init={
                          "id": generator.Sequence(),
                          "name": generator.Name(),
                          "surname": generator.Name(),
                          "job": Job(),
                          "photo_name": Photo()
                      })

        # Create 10 users
        for elem in faker.create(10):
            print("Adding assistant: %s" % elem)
            self.db.session.add(elem)
コード例 #11
0
    def run(self):
        faker = Faker(
            cls=Question,
            init={
                "question":
                generator.String(
                    'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae nulla pretium, euismod neque ut, feugiat est. Curabitur eleifend lacus vel malesuada ornare. Suspendisse volutpat turpis elit, a facilisis orci facilisis sed. Praesent sed nulla non massa tempor tincidunt. Curabitur lobortis ac elit non ullamcorper. Fusce auctor egestas libero. Aliquam vel rutrum tellus. Phasellus ut quam condimentum, tempus tellus vel, faucibus nulla. Duis eu ligula sodales, viverra dolor at, tincidunt elit. Nunc ut pharetra tellus, sit amet euismod quam. Suspendisse aliquet ligula fermentum, suscipit lacus vitae, imperdiet est. In consectetur lacus at dignissim facilisis.'
                ),
                "like_count":
                generator.Integer(start=0, end=100)
            })

        for question in faker.create(20):
            print("Adding question: %s" % question)
            self.db.session.add(question)
コード例 #12
0
ファイル: user.py プロジェクト: negrosdev/negros.dev
    def run(self):
        faker = Faker(
            cls=User,
            init={
                "name": generator.Name(),
                "email": "*****@*****.**",
                "password": "******",
                "description": generator.Sequence(),
                "role": ERole.ADMIN,
            },
        )

        for user in faker.create():
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #13
0
    def run(self):

        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=User,
                      init={
                          "id":
                          generator.Sequence(),
                          "email":
                          "*****@*****.**",
                          "password_hash":
                          generate_password_hash(Config.ADMIN_PASSWORD)
                      })

        payload = faker.create()
        print(payload)
        self.db.session.add(payload[0])
コード例 #14
0
    def run(self):
        date = datetime.now()

        faker = Faker(cls=Trucker,
                      init={
                          'name': generator.Name(),
                          'age': generator.Integer(start=18, end=60),
                          'whatsapp': generator.String(r'+55\d{11}'),
                          'last_latitude': '-10',
                          'last_longitude': '-10',
                          'created_date': date
                      })

        for trucker in faker.create(5):
            print('Adding trucker: %s' % trucker)
            self.db.session.add(trucker)
コード例 #15
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        name = generator.Name()
        faker = Faker(
            cls=User,
            init={
                "name": name,
                "email": ''.join(random.choice(string.ascii_letters) for i in range(10)) + "@mail.com",
                "password": "******"
            }
        )

        # Create 1 user
        for user in faker.create(1):
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #16
0
    def run(self):
        today = date.today()
        faker = Faker(cls=Assistant,
                      init={
                          "id": generator.Sequence(),
                          "firstname": generator.Name(),
                          "lastname": generator.Name(),
                          "email": generator.String(),
                          "occupation": generator.String(),
                          "creationdate": today,
                          "filename": "default.png"
                      })

        for assistant in faker.create(5):
            print("Adding assistant: %s" % Assistant)
            self.db.session.add(assistant)
コード例 #17
0
    def run(self):
        faker = Faker(
            cls=Content,
            init={
                "name": generator.Name(),
                "text": F().paragraph(nb_sentences=12),
                "description": F().paragraph(nb_sentences=1),
                "author_id": User.query.first().id,
                "embeded": """
<div style="padding:56.25% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/184374359?h=71fdbf5881&title=0&byline=0&portrait=0" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>        
        """,
            },
        )

        for content in faker.create(5):
            print("Adding content: %s" % content)
            self.db.session.add(content)
コード例 #18
0
    def run(self):
        faker = Faker(cls=Article_categories,
                      init={
                          "category_id":
                          generator.Sequence(),
                          "category_name":
                          CustomFromListGenerator([
                              "games", "music", "travel", "sport",
                              "documentary", "captured", "technology",
                              "fashion", "movies"
                          ]),
                      })

        for record in faker.create(9):
            print("Adding:", record)
            self.db.session.add(record)
        self.db.session.commit()
コード例 #19
0
ファイル: seeder.py プロジェクト: baton96/Assistant-Manager
 def run(self):
     for model in self.db.Model._decl_class_registry.values():
         if hasattr(
                 model,
                 '__tablename__') and model.__tablename__ == "assistants":
             Assistant = model
     faker = Faker(cls=Assistant,
                   init={
                       'name': FullNameGenerator(),
                       'department': DepartmentGenerator(),
                       'job': JobGenerator(),
                   })
     assistants = [a for a in faker.create(3)]
     self.db.session.add_all(assistants)
     self.db.session.commit()
     for assistant in assistants:
         generatePhoto(assistant.id)
コード例 #20
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=models.User,
                      init={
                          "id": None,
                          "name": generator.String('[a-z]\d{4}\c{3}'),
                          "created_at": None,
                          "created_by": 'system',
                          "updated_at": None,
                          "updated_by": '',
                          "email": generator.String('[a-z]\d{4}\c{3}@test.com')
                      })

        # Create 3 users
        for user in faker.create(3):
            print("Adding user: %s" % user)
            # Flask-Seeder will by default commit all changes to the database.
            self.db.session.add(user)
コード例 #21
0
ファイル: seeders.py プロジェクト: Duckolyte/the-zebro-api
    def run(self):
        faker = Faker(
            cls=Mission,
            init={
                'userId':
                generators.RelationalForeignKey(user_uuids_container),
                'parcSection':
                generators.GenericListItem(generic_list=parc_sections),
                'timeStamp':
                generators.DateTime(start_date=d1, end_date=d2),
                'id':
                generators.RelationalPrimaryKey(mission_uuids_container)
            })

        for mission in faker.create(
                mission_uuids_container.container_list_length()):
            print("Adding mission: %s" % mission)
            self.db.session.add(mission)
コード例 #22
0
ファイル: seeders.py プロジェクト: Duckolyte/the-zebro-api
    def run(self):
        faker = Faker(
            cls=Spot,
            init={
                'missionId':
                generators.RelationalForeignKey(mission_uuids_container),
                'observationQualityCode':
                generators.GenericListItem(generic_list=obs_quality_codes),
                'observationDateTime':
                generators.DateTime(start_date=obs_date_start,
                                    end_date=obs_date_end),
                'id':
                generators.RelationalPrimaryKey(spot_uuids_container)
            })

        for spot in faker.create(spot_uuids_container.container_list_length()):
            print("Adding spot: %s" % spot)
            self.db.session.add(spot)
コード例 #23
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=Assistants,
                      init={
                          "first_name": generator.Name(),
                          "last_name": generator.Name(),
                          "username": generator.Name(),
                          "profession":
                          job_titles[randint(0,
                                             len(job_titles) - 1)],
                          "picture": "avatar_temporary.jpg"
                      })

        # Create 5 users
        for assist in faker.create(5):
            print(
                f"Adding user: {assist.username}, {assist.first_name}, {assist.last_name}, {assist.profession}"
            )
            self.db.session.add(assist)
コード例 #24
0
    def run(self):
        obj = db.session.query(Job).order_by(Job.id.desc()).first()

        faker = Faker(
            cls=Assistant,
            init={
                "name": generator.Name(),
                "surname": generator.Name(),
                "picture_file": generator.String('(seeder_prof/)\d(.jpg)'),
                "job": generator.Integer(start=1, end=obj.id)
            }
        )

        # Create 15 assistants
        for assistant in faker.create(15):
            job = Job.query.filter_by(id=assistant.job).first()
            assistant.job = job.text
            print("Adding user: %s" % assistant)
            self.db.session.add(assistant)
コード例 #25
0
ファイル: seeders.py プロジェクト: Duckolyte/the-zebro-api
    def run(self):
        faker = Faker(
            cls=Observation,
            init={
                'spotId':
                generators.RelationalForeignKey(spot_uuids_container),
                'animalName': generator.Name(),
                'sex': generators.GenericListItem(sex_enum),
                'age': generators.GenericListItem(age_enum),
                'pregnancyGrade':
                generators.GenericListItem(pregnancy_grade_enum),
                'id':
                generators.RelationalPrimaryKey(observation_uuids_container)
            })

        for observation in faker.create(
                observation_uuids_container.container_list_length()):
            print("Adding observation: %s" % observation)
            self.db.session.add(observation)
コード例 #26
0
    def run(self):
        _id = generator.Sequence()

        faker_for_state = Faker(cls=State,
                                init={
                                    'id': _id,
                                    'name': StateGeneratorSequence(),
                                    'lat': "99.000",
                                    'lng': "99.000",
                                })

        faker_for_total = Faker(cls=State,
                                init={
                                    'id': _id,
                                    'name': 'Total',
                                    'lat': f"00.000",
                                    'lng': f"00.000",
                                })

        for state in faker_for_total.create(1):
            print("Adding state: %s" % state)
            self.db.session.add(state)

        for state in faker_for_state.create(27):
            print("Adding state: %s" % state)
            self.db.session.add(state)
コード例 #27
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        faker = Faker(cls=User,
                      init={
                          "name": "",
                          "email": "",
                          "password": "******"
                      })

        # Create 3 users
        names = ["shajalahamed", "hello", "go"]
        emails = [
            "*****@*****.**", "*****@*****.**", "*****@*****.**"
        ]
        counter = 0
        for user in faker.create(3):
            user.email = emails[counter]
            user.name = names[counter]
            # user.password= bcrypt.hashpw('password'.encode(), bcrypt.gensalt()).decode()
            counter += 1
            print("Adding user: %s" % user)
            self.db.session.add(user)
コード例 #28
0
    def run(self):

        faker_for_city = Faker(cls=City,
                               init={
                                   'id':
                                   generator.Sequence(start=1, end=1000),
                                   'ibge_id':
                                   generator.Integer(start=300000, end=399999),
                                   'country':
                                   'Brazil',
                                   'city':
                                   'Test',
                                   'deaths':
                                   1,
                                   'state_id':
                                   generator.Integer(start=2, end=28),
                                   'totalcases':
                                   generator.Integer(start=1, end=10)
                               })

        for case in faker_for_city.create(500):
            print("Adding city case: %s" % case)
            self.db.session.add(case)
コード例 #29
0
    def run(self):
        countries = [{
            "code": "VN",
            "name": "Viet Nam"
        }, {
            "code": "SG",
            "name": "Singapore"
        }]

        # Create a new Faker and tell it how to create Country objects
        index = 1
        for country in countries:
            print(country)
            faker = Faker(cls=Country,
                          init={
                              "id": index,
                              "code": country['code'],
                              "name": country['name']
                          })

            payload = faker.create()
            self.db.session.add(payload[0])
            index += 1
コード例 #30
0
    def run(self):
        # Create a new Faker and tell it how to create User objects
        # name = generator.Name()
        # print( vars(name) )
        # exit("Exit...")

        role = ["admin", "CEO", "manager", "secretary", "staff"]
        department = [
            "IT", "Finance", "Marketing", "Research and Development",
            "Executive"
        ]

        faker = Faker(cls=User,
                      init={
                          "name": "Fitria Amastini",
                          "email": '*****@*****.**',
                          "password": "******",
                          "role": role[0],
                          "department": department[0]
                      })

        # Create 25 user random
        for user in faker.create(1):
            print("Adding user: %s" % user)
            self.db.session.add(user)

        # name = generator.Name()

        # Create 25 user random
        for i in range(5):
            name = generator.Name()
            role_idx = i % len(role)
            depart_idx = i % len(department)

            faker_2 = Faker(
                cls=User,
                init={
                    "name":
                    name,
                    "email":
                    ''.join(
                        random.choice(string.ascii_letters)
                        for i in range(10)) + "@mail.com",
                    "password":
                    "******",
                    "role":
                    role[role_idx],
                    "department":
                    department[depart_idx]
                    # "role": role[random.randint(0, len(role)-1)],
                    # "department": department[random.randint(0, len(department)-1)]
                })

            for user_2 in faker_2.create(1):
                print("Adding user: %s" % user_2)
                self.db.session.add(user_2)