mirror of https://github.com/zulip/zulip.git
tests: Move zerver/fixtures to zerver/tests/fixtures for clarity.
Fixes #9153.
This commit is contained in:
parent
d0801dd602
commit
76d6c71595
|
@ -38,7 +38,7 @@ The Python-Markdown implementation is tested by
|
|||
`frontend_tests/node_tests/markdown.js`.
|
||||
|
||||
A shared set of fixed test data ("test fixtures") is present in
|
||||
`zerver/fixtures/markdown_test_cases.json`, and is automatically used
|
||||
`zerver/tests/fixtures/markdown_test_cases.json`, and is automatically used
|
||||
by both test suites; as a result, it is the preferred place to add new
|
||||
tests for Zulip's markdown system. Some important notes on reading
|
||||
this file:
|
||||
|
@ -99,7 +99,7 @@ places:
|
|||
`static/third/marked/lib/marked.js`), or `markdown.contains_backend_only_syntax` if
|
||||
your changes won't be supported in the frontend processor.
|
||||
* If desired, the typeahead logic in `static/js/composebox_typeahead.js`.
|
||||
* The test suite, probably via adding entries to `zerver/fixtures/markdown_test_cases.json`.
|
||||
* The test suite, probably via adding entries to `zerver/tests/fixtures/markdown_test_cases.json`.
|
||||
* The in-app markdown documentation (`templates/zerver/markdown_help.html`).
|
||||
* The list of changes to markdown at the end of this document.
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ reads a bunch of sample inputs from a JSON fixture file, feeds them
|
|||
to our GitHub integration code, and then verifies the output against
|
||||
expected values from the same JSON fixture file.
|
||||
|
||||
Our fixtures live in `zerver/fixtures`.
|
||||
Our fixtures live in `zerver/tests/fixtures`.
|
||||
|
||||
### Mocks and stubs
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ module.prototype.hot = {
|
|||
|
||||
// Set up fixtures.
|
||||
global.read_fixture_data = (fn) => {
|
||||
var full_fn = path.join(__dirname, '../../zerver/fixtures/', fn);
|
||||
var full_fn = path.join(__dirname, '../../zerver/tests/fixtures/', fn);
|
||||
var data = JSON.parse(fs.readFileSync(full_fn, 'utf8', 'r'));
|
||||
return data;
|
||||
};
|
||||
|
|
|
@ -351,7 +351,7 @@ To trigger a notification using this webhook, use
|
|||
|
||||
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:/srv/zulip$
|
||||
./manage.py send_webhook_fixture_message \
|
||||
--fixture=zerver/fixtures/helloworld/hello.json \
|
||||
--fixture=zerver/tests/fixtures/helloworld/hello.json \
|
||||
'--url=http://localhost:9991/api/v1/external/helloworld?api_key=<api_key>'
|
||||
|
||||
Or, use curl:
|
||||
|
|
|
@ -727,7 +727,7 @@ def build_custom_checkers(by_lang):
|
|||
'exclude': set(['zerver/webhooks/']),
|
||||
'description': 'Fix tab-based whitespace'},
|
||||
{'pattern': ':[\"\[\{]',
|
||||
'exclude': set(['zerver/webhooks/', 'zerver/fixtures/']),
|
||||
'exclude': set(['zerver/webhooks/', 'zerver/tests/fixtures/']),
|
||||
'description': 'Require space after : in JSON'},
|
||||
] # type: RuleList
|
||||
markdown_rules = markdown_whitespace_rules + prose_style_rules + [
|
||||
|
|
|
@ -10,6 +10,5 @@ templates/zilencer
|
|||
puppet/zulip_ops
|
||||
zproject/dev_settings.py
|
||||
zproject/test_settings.py
|
||||
zerver/fixtures
|
||||
zerver/tests
|
||||
frontend_tests
|
||||
|
|
|
@ -8,7 +8,7 @@ import zulip
|
|||
|
||||
zulip_client = zulip.Client(site="http://localhost:9991", client="ZulipGithubPayloadSender/0.1")
|
||||
|
||||
payload_dir = "zerver/fixtures/github"
|
||||
payload_dir = "zerver/tests/fixtures/github"
|
||||
for filename in os.listdir(payload_dir):
|
||||
with open(os.path.join(payload_dir, filename)) as f:
|
||||
req = json.loads(f.read())
|
||||
|
|
|
@ -11,7 +11,7 @@ EOF
|
|||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p zerver/fixtures
|
||||
mkdir -p zerver/tests/fixtures
|
||||
|
||||
"$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" zulip zulip_test zulip_test_base zulip_test_template
|
||||
|
||||
|
@ -32,7 +32,7 @@ sh "$(dirname "$0")/../../scripts/setup/flush-memcached"
|
|||
zerver.UserProfile zerver.Stream zerver.Recipient \
|
||||
zerver.Subscription zerver.Message zerver.Huddle zerver.Realm \
|
||||
zerver.UserMessage zerver.Client \
|
||||
zerver.DefaultStream > zerver/fixtures/messages.json
|
||||
zerver.DefaultStream > zerver/tests/fixtures/messages.json
|
||||
|
||||
# create pristine template database, for fast fixture restoration after tests are run.
|
||||
psql -h localhost postgres zulip_test << EOF
|
||||
|
|
|
@ -26,8 +26,9 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
|||
from django.conf import settings
|
||||
from zerver.lib.utils import split_by
|
||||
|
||||
FIXTURE_FILE = os.path.join(os.path.dirname(__file__), '../zerver/fixtures/authors.json')
|
||||
duplicate_commits_file = os.path.join(os.path.dirname(__file__), '../zerver/fixtures/duplicate_commits.json')
|
||||
FIXTURE_FILE = os.path.join(os.path.dirname(__file__), '../zerver/tests/fixtures/authors.json')
|
||||
duplicate_commits_file = os.path.join(os.path.dirname(__file__),
|
||||
'../zerver/tests/fixtures/duplicate_commits.json')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--max-retries', type=int, default=3,
|
||||
|
@ -143,7 +144,7 @@ def run_production() -> None:
|
|||
|
||||
def copy_fixture() -> None:
|
||||
"""
|
||||
Copy test fixture file from zerver/fixtures. This is used to avoid
|
||||
Copy test fixture file from zerver/tests/fixtures. This is used to avoid
|
||||
constantly fetching data from Github during testing.
|
||||
"""
|
||||
subprocess.check_call(['cp', FIXTURE_FILE, settings.CONTRIBUTORS_DATA])
|
||||
|
|
|
@ -4,7 +4,7 @@ import random
|
|||
from typing import List, Dict, Any, Text, Optional
|
||||
|
||||
def load_config() -> Dict[str, Any]:
|
||||
with open("zerver/fixtures/config.generate_data.json", "r") as infile:
|
||||
with open("zerver/tests/fixtures/config.generate_data.json", "r") as infile:
|
||||
config = ujson.load(infile)
|
||||
|
||||
return config
|
||||
|
|
|
@ -3,7 +3,7 @@ from typing import Dict
|
|||
|
||||
# Warning: If you change this parsing, please test using
|
||||
# zerver/tests/test_decorators.py
|
||||
# And extend zerver/fixtures/user_agents_unique with any new test cases
|
||||
# And extend zerver/tests/fixtures/user_agents_unique with any new test cases
|
||||
def parse_user_agent(user_agent: str) -> Dict[str, str]:
|
||||
match = re.match("^(?P<name>[^/ ]*[^0-9/(]*)(/(?P<version>[^/ ]*))?([ /].*)?$", user_agent)
|
||||
assert match is not None
|
||||
|
|
|
@ -235,7 +235,7 @@ class BugdownTest(ZulipTestCase):
|
|||
|
||||
def load_bugdown_tests(self) -> Tuple[Dict[Text, Any], List[List[Text]]]:
|
||||
test_fixtures = {}
|
||||
data_file = open(os.path.join(os.path.dirname(__file__), '../fixtures/markdown_test_cases.json'), 'r')
|
||||
data_file = open(os.path.join(os.path.dirname(__file__), 'fixtures/markdown_test_cases.json'), 'r')
|
||||
data = ujson.loads('\n'.join(data_file.readlines()))
|
||||
for test in data['regular_tests']:
|
||||
test_fixtures[test['name']] = test
|
||||
|
|
|
@ -1321,7 +1321,7 @@ class TestUserAgentParsing(ZulipTestCase):
|
|||
def test_user_agent_parsing(self) -> None:
|
||||
"""Test for our user agent parsing logic, using a large data set."""
|
||||
user_agents_parsed = defaultdict(int) # type: Dict[str, int]
|
||||
user_agents_path = os.path.join(settings.DEPLOY_ROOT, "zerver/fixtures/user_agents_unique")
|
||||
user_agents_path = os.path.join(settings.DEPLOY_ROOT, "zerver/tests/fixtures/user_agents_unique")
|
||||
for line in open(user_agents_path).readlines():
|
||||
line = line.strip()
|
||||
match = re.match('^(?P<count>[0-9]+) "(?P<user_agent>.*)"$', line)
|
||||
|
|
|
@ -197,7 +197,7 @@ class AboutPageTest(ZulipTestCase):
|
|||
# This block has unreliable test coverage due to the implicit
|
||||
# caching here, so we exclude it from coverage.
|
||||
if not os.path.exists(settings.CONTRIBUTORS_DATA):
|
||||
# Copy the fixture file in `zerver/fixtures` to `static/generated`
|
||||
# Copy the fixture file in `zerver/tests/fixtures` to `static/generated`
|
||||
update_script = os.path.join(os.path.dirname(__file__),
|
||||
'../../tools/update-authors-json') # nocoverage
|
||||
subprocess.check_call([update_script, '--use-fixture']) # nocoverage
|
||||
|
|
|
@ -325,7 +325,7 @@ class TestReplyExtraction(ZulipTestCase):
|
|||
|
||||
self.assertEqual(message.content, 'Reply')
|
||||
|
||||
MAILS_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "fixtures", "email")
|
||||
MAILS_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tests", "fixtures", "email")
|
||||
|
||||
|
||||
class TestScriptMTA(ZulipTestCase):
|
||||
|
|
|
@ -347,7 +347,7 @@ class NarrowBuilderTest(ZulipTestCase):
|
|||
class BuildNarrowFilterTest(TestCase):
|
||||
def test_build_narrow_filter(self) -> None:
|
||||
fixtures_path = os.path.join(os.path.dirname(__file__),
|
||||
'../fixtures/narrow.json')
|
||||
'fixtures/narrow.json')
|
||||
scenarios = ujson.loads(open(fixtures_path, 'r').read())
|
||||
self.assertTrue(len(scenarios) == 9)
|
||||
for scenario in scenarios:
|
||||
|
|
|
@ -484,7 +484,7 @@ class TestMissedMessages(ZulipTestCase):
|
|||
# Run `relative_to_full_url()` function over test fixtures present in
|
||||
# 'markdown_test_cases.json' and check that it converts all the relative
|
||||
# URLs to absolute URLs.
|
||||
fixtures_file = os.path.join(settings.DEPLOY_ROOT, "zerver",
|
||||
fixtures_file = os.path.join(settings.DEPLOY_ROOT, "zerver", "tests",
|
||||
"fixtures", "markdown_test_cases.json")
|
||||
fixtures = ujson.load(open(fixtures_file))
|
||||
test_fixtures = {}
|
||||
|
|
|
@ -43,7 +43,7 @@ from zilencer.models import RemoteZulipServer, RemotePushDeviceToken
|
|||
from django.utils.timezone import now
|
||||
|
||||
ZERVER_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
FIXTURES_FILE_PATH = os.path.join(ZERVER_DIR, "fixtures", "markdown_test_cases.json")
|
||||
FIXTURES_FILE_PATH = os.path.join(ZERVER_DIR, "tests", "fixtures", "markdown_test_cases.json")
|
||||
|
||||
class BouncerTestCase(ZulipTestCase):
|
||||
def setUp(self) -> None:
|
||||
|
|
|
@ -154,7 +154,7 @@ class TestReport(ZulipTestCase):
|
|||
|
||||
def test_report_csp_violations(self) -> None:
|
||||
fixture_data_file = open(os.path.join(os.path.dirname(__file__),
|
||||
'../fixtures/csp_report.json'), 'r')
|
||||
'fixtures/csp_report.json'), 'r')
|
||||
fixture_data = ujson.load(fixture_data_file)
|
||||
params = ujson.dumps(fixture_data)
|
||||
result = self.client_post("/report/csp_violations", params, content_type="application/json")
|
||||
|
|
|
@ -473,7 +473,7 @@ class SlackImporter(ZulipTestCase):
|
|||
mock_build_avatar: mock.Mock,
|
||||
mock_process_uploads: mock.Mock,
|
||||
mock_attachment: mock.Mock) -> None:
|
||||
test_slack_dir = os.path.join(settings.DEPLOY_ROOT, "zerver", "fixtures",
|
||||
test_slack_dir = os.path.join(settings.DEPLOY_ROOT, "zerver", "tests", "fixtures",
|
||||
"slack_fixtures")
|
||||
test_slack_zip_file = os.path.join(test_slack_dir, "test_slack_importer.zip")
|
||||
test_slack_unzipped_file = os.path.join(test_slack_dir, "test_slack_importer")
|
||||
|
@ -489,7 +489,7 @@ class SlackImporter(ZulipTestCase):
|
|||
# Also the unzipped data file should be removed if the test fails at 'do_convert_data'
|
||||
rm_tree(test_slack_unzipped_file)
|
||||
|
||||
user_data_fixture = os.path.join(settings.DEPLOY_ROOT, "zerver", "fixtures",
|
||||
user_data_fixture = os.path.join(settings.DEPLOY_ROOT, "zerver", "tests", "fixtures",
|
||||
"slack_fixtures", "user_data.json")
|
||||
mock_get_slack_api_data.side_effect = [ujson.load(open(user_data_fixture))['members'], {}]
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class SlackMessageConversion(ZulipTestCase):
|
|||
|
||||
def load_slack_message_conversion_tests(self) -> Dict[Any, Any]:
|
||||
test_fixtures = {}
|
||||
data_file = open(os.path.join(os.path.dirname(__file__), '../fixtures/slack_message_conversion.json'), 'r')
|
||||
data_file = open(os.path.join(os.path.dirname(__file__), 'fixtures/slack_message_conversion.json'), 'r')
|
||||
data = ujson.loads('\n'.join(data_file.readlines()))
|
||||
for test in data['regular_tests']:
|
||||
test_fixtures[test['name']] = test
|
||||
|
|
|
@ -11,7 +11,7 @@ from zerver.models import Realm, UserProfile
|
|||
from zilencer.lib.stripe import StripeError, save_stripe_token, catch_stripe_errors
|
||||
from zilencer.models import Customer
|
||||
|
||||
fixture_data_file = open(os.path.join(os.path.dirname(__file__), '../fixtures/stripe.json'), 'r')
|
||||
fixture_data_file = open(os.path.join(os.path.dirname(__file__), 'fixtures/stripe.json'), 'r')
|
||||
fixture_data = ujson.load(fixture_data_file)
|
||||
|
||||
def mock_list_sources(*args: Any, **kwargs: Any) -> ListObject:
|
||||
|
|
|
@ -17,7 +17,7 @@ To trigger a notification using this webhook, use
|
|||
```
|
||||
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:/srv/zulip$
|
||||
./manage.py send_webhook_fixture_message \
|
||||
> --fixture=zerver/fixtures/helloworld/hello.json \
|
||||
> --fixture=zerver/tests/fixtures/helloworld/hello.json \
|
||||
> '--url=http://localhost:9991/api/v1/external/helloworld?api_key=<api_key>'
|
||||
|
||||
```
|
||||
|
|
|
@ -317,7 +317,7 @@ class Command(BaseCommand):
|
|||
# in the config.generate_data.json data set. This makes it
|
||||
# possible for populate_db to run happily without Internet
|
||||
# access.
|
||||
with open("zerver/fixtures/docs_url_preview_data.json", "r") as f:
|
||||
with open("zerver/tests/fixtures/docs_url_preview_data.json", "r") as f:
|
||||
urls_with_preview_data = ujson.load(f)
|
||||
for url in urls_with_preview_data:
|
||||
cache_set(url, urls_with_preview_data[url], PREVIEW_CACHE_NAME)
|
||||
|
|
Loading…
Reference in New Issue