Skip to content

Commit

Permalink
Add special string replies; remove magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier authored and eloquence committed Jul 7, 2020
1 parent d552de6 commit 9d82324
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
16 changes: 7 additions & 9 deletions securedrop/create-dev-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import os
import argparse
import math
from itertools import cycle

from flask import current_app
Expand All @@ -15,14 +16,11 @@
from sdconfig import config
from db import db
from models import Journalist, Reply, Source, Submission
from specialstrings import submissions
from specialstrings import strings


replies = cycle([
'This is a test reply without markup!',
'This is a test reply with markup and characters such as \, \\, \', \" and ". ' + # noqa: W605, E501
'<strong>This text should not be bold</strong>!'
])
submissions = cycle(strings)
replies = cycle(strings)


def main(staging=False):
Expand Down Expand Up @@ -54,9 +52,9 @@ def main(staging=False):

NUM_SOURCES = os.getenv('NUM_SOURCES', 2)
if NUM_SOURCES == "ALL":
# We want all strings, 14 sources will give all the strings based
# on current string count.
NUM_SOURCES = 14
# We ingest two strings per source, so this will create the required
# number of sources to include all special strings
NUM_SOURCES = math.ceil(len(strings) / 2)
# Add test sources and submissions
num_sources = int(NUM_SOURCES)
for i in range(1, num_sources + 1):
Expand Down
18 changes: 3 additions & 15 deletions securedrop/specialstrings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from itertools import cycle


strings = [
"""This is a test message without markup!""",
"""This is a test message with markup and characters such as \, \\, \', \" and ". """ + # noqa: W605, E501
"""<strong>This text should not be bold</strong>!""",
"""~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%""",
"""Ω≈ç√∫˜µ≤≥÷
åß∂ƒ©˙∆˚¬…æ
Expand Down Expand Up @@ -142,15 +142,3 @@
𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐
⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢""", # noqa: W605, E501
]

submission_list = ["""This is a test submission without markup!""",
"""This is a test submission with markup and characters such as \, \\, \', \" and ". """ + # noqa: W605, E501
"""<strong>This text should not be bold</strong>!"""]
submission_list.extend(strings)
submissions = cycle(submission_list)

replies_list = ['This is a test reply without markup!',
'This is a test reply with markup and characters such as \, \\, \', \" and ". ' + # noqa: W605, E501
'<strong>This text should not be bold</strong>!']
replies_list.extend(strings)
replies = cycle(replies_list)

0 comments on commit 9d82324

Please sign in to comment.