Skip to content

Commit

Permalink
Add source detail to create-dev-data output
Browse files Browse the repository at this point in the history
As sources are being added, include the count in the output, to give a
better idea of progress.
  • Loading branch information
rmol committed Apr 1, 2020
1 parent 5986f7d commit 5ab291f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions securedrop/create-dev-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def main(staging=False):

# Add test sources and submissions
num_sources = int(os.getenv('NUM_SOURCES', 2))
for _ in range(num_sources):
create_source_and_submissions()
for i in range(1, num_sources + 1):
create_source_and_submissions(i, num_sources)


def add_test_user(username, password, otp_secret, is_admin=False):
Expand All @@ -71,7 +71,7 @@ def add_test_user(username, password, otp_secret, is_admin=False):
db.session.rollback()


def create_source_and_submissions(num_submissions=2, num_replies=2):
def create_source_and_submissions(source_index, source_count, num_submissions=2, num_replies=2):
# Store source in database
codename = current_app.crypto_util.genrandomid()
filesystem_id = current_app.crypto_util.hash_codename(codename)
Expand Down Expand Up @@ -115,9 +115,13 @@ def create_source_and_submissions(num_submissions=2, num_replies=2):

db.session.commit()

print("Test source (codename: '{}', journalist designation '{}') "
"added with {} submissions and {} replies".format(
codename, journalist_designation, num_submissions, num_replies))
print(
"Test source {}/{} (codename: '{}', journalist designation '{}') "
"added with {} submissions and {} replies".format(
source_index, source_count, codename, journalist_designation,
num_submissions, num_replies
)
)


if __name__ == "__main__": # pragma: no cover
Expand Down

0 comments on commit 5ab291f

Please sign in to comment.