Skip to content

Commit 9d82324

Browse files
Allie CrevierErik Moeller
authored andcommitted
Add special string replies; remove magic number
1 parent d552de6 commit 9d82324

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

securedrop/create-dev-data.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import datetime
55
import os
66
import argparse
7+
import math
78
from itertools import cycle
89

910
from flask import current_app
@@ -15,14 +16,11 @@
1516
from sdconfig import config
1617
from db import db
1718
from models import Journalist, Reply, Source, Submission
18-
from specialstrings import submissions
19+
from specialstrings import strings
1920

2021

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

2725

2826
def main(staging=False):
@@ -54,9 +52,9 @@ def main(staging=False):
5452

5553
NUM_SOURCES = os.getenv('NUM_SOURCES', 2)
5654
if NUM_SOURCES == "ALL":
57-
# We want all strings, 14 sources will give all the strings based
58-
# on current string count.
59-
NUM_SOURCES = 14
55+
# We ingest two strings per source, so this will create the required
56+
# number of sources to include all special strings
57+
NUM_SOURCES = math.ceil(len(strings) / 2)
6058
# Add test sources and submissions
6159
num_sources = int(NUM_SOURCES)
6260
for i in range(1, num_sources + 1):

securedrop/specialstrings.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from itertools import cycle
2-
3-
41
strings = [
2+
"""This is a test message without markup!""",
3+
"""This is a test message with markup and characters such as \, \\, \', \" and ". """ + # noqa: W605, E501
4+
"""<strong>This text should not be bold</strong>!""",
55
"""~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%""",
66
"""Ω≈ç√∫˜µ≤≥÷
77
åß∂ƒ©˙∆˚¬…æ
@@ -142,15 +142,3 @@
142142
𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐
143143
⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢""", # noqa: W605, E501
144144
]
145-
146-
submission_list = ["""This is a test submission without markup!""",
147-
"""This is a test submission with markup and characters such as \, \\, \', \" and ". """ + # noqa: W605, E501
148-
"""<strong>This text should not be bold</strong>!"""]
149-
submission_list.extend(strings)
150-
submissions = cycle(submission_list)
151-
152-
replies_list = ['This is a test reply without markup!',
153-
'This is a test reply with markup and characters such as \, \\, \', \" and ". ' + # noqa: W605, E501
154-
'<strong>This text should not be bold</strong>!']
155-
replies_list.extend(strings)
156-
replies = cycle(replies_list)

0 commit comments

Comments
 (0)