zulip/zephyr/tests/generate-fixtures

30 lines
1.2 KiB
Bash
Executable File

#!/bin/sh -e
if [ -e zephyr/tests/zephyrdb.test.pristine ]; then
if [ "$1" != "--force" ]; then
cp zephyr/tests/zephyrdb.test.pristine zephyr/tests/zephyrdb.test
exit 0
fi
fi
mkdir -p zephyr/fixtures
rm -f zephyr/tests/zephyrdb.test
rm -f zephyr/tests/zephyrdb.test.pristine
# Remove time.pyc to try to prevent it from screwing people importing
# time from inside zephyr.lib. We can drop this hack after a bit.
rm -f zephyr/lib/time.pyc
python manage.py syncdb --noinput --settings=humbug.test_settings
python manage.py migrate --settings=humbug.test_settings --all
# This next line can be simplified to "-n0" once we fix our app with 0 messages.
python manage.py populate_db --settings=humbug.test_settings --test-suite -n2 \
--threads=1 --huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
python manage.py dumpdata --settings=humbug.test_settings \
auth.User zephyr.UserProfile zephyr.Stream zephyr.Recipient \
zephyr.Subscription zephyr.Message zephyr.Huddle zephyr.Realm \
zephyr.UserMessage zephyr.Client \
zephyr.DefaultStream > zephyr/fixtures/messages.json
cp zephyr/tests/zephyrdb.test zephyr/tests/zephyrdb.test.pristine