test-backend: Move `test_messages.json` to `var/<uuid>/test-backend`.

This commit is contained in:
Wyatt Hoodes 2019-06-09 08:27:12 -10:00 committed by Tim Abbott
parent 3c1982ecab
commit fb58b54293
2 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,9 @@ import itertools
import ujson
import random
from typing import List, Dict, Any
import os
from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path
def load_config() -> Dict[str, Any]:
with open("zerver/tests/fixtures/config.generate_data.json", "r") as infile:
@ -169,7 +172,8 @@ def create_test_data() -> None:
paragraphs = parse_file(config, gens, config["corpus"]["filename"])
write_file(paragraphs, "var/test_messages.json")
write_file(paragraphs, os.path.join(get_or_create_dev_uuid_var_path('test-backend'),
"test_messages.json"))
config = load_config() # type: Dict[str, Any]

View File

@ -30,6 +30,8 @@ from zerver.models import CustomProfileField, DefaultStream, Message, Realm, Rea
email_to_username, get_client, get_huddle, get_realm, get_stream, \
get_system_bot, get_user, get_user_profile_by_id
from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path
settings.TORNADO_SERVER = None
# Disable using memcached caches to avoid 'unsupported pickle
# protocol' errors if `populate_db` is run with a different Python
@ -559,7 +561,8 @@ def send_messages(data: Tuple[int, Sequence[Sequence[int]], Mapping[str, Any],
(tot_messages, personals_pairs, options, output, random_seed) = data
random.seed(random_seed)
with open("var/test_messages.json", "r") as infile:
with open(os.path.join(get_or_create_dev_uuid_var_path('test-backend'),
"test_messages.json"), "r") as infile:
dialog = ujson.load(infile)
random.shuffle(dialog)
texts = itertools.cycle(dialog)