Skip to content

Commit

Permalink
refactor: move PID specific Faker instance into relevant generator cl…
Browse files Browse the repository at this point in the history
…ass #287
  • Loading branch information
MRichards99 committed Nov 11, 2021
1 parent 18379be commit 4f282dc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions util/icat_db_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
faker = Faker()
Faker.seed(SEED)

pid_faker = Faker()
pid_faker.seed_instance(SEED)


engine = create_engine(
config.get_config_value(APIConfigOptions.DB_URL),
Expand Down Expand Up @@ -426,6 +423,8 @@ def generate_user_groups(i):
class StudyGenerator(Generator):
tier = 3
amount = UserGenerator.amount
pid_faker = Faker()
pid_faker.seed_instance(SEED)

def generate(self):
for i in range(1, self.amount):
Expand All @@ -437,7 +436,7 @@ def generate_studies(i):
apply_common_attributes(study, i)
study.startDate = get_start_date(i)
study.status = faker.random_int(0, 1)
study.pid = pid_faker.isbn10(separator="-")
study.pid = StudyGenerator.pid_faker.isbn10(separator="-")
study.userID = i
post_entity(study)

Expand Down

0 comments on commit 4f282dc

Please sign in to comment.