py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-01-13 13:50:39 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2017-02-05 21:24:28 +01:00
|
|
|
# check for the venv
|
|
|
|
from lib import sanity_check
|
|
|
|
sanity_check.check_venv(__file__)
|
2017-01-13 13:50:39 +01:00
|
|
|
|
2017-02-05 21:24:28 +01:00
|
|
|
import django
|
2017-08-28 01:03:45 +02:00
|
|
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
sys.path.insert(0, ZULIP_PATH)
|
|
|
|
os.chdir(ZULIP_PATH)
|
2017-01-13 13:50:39 +01:00
|
|
|
|
|
|
|
from zulip import Client
|
|
|
|
|
|
|
|
from tools.lib.test_server import test_server_running
|
2018-02-06 21:04:07 +01:00
|
|
|
from zerver.lib.api_test_helpers import test_the_api, test_invalid_api_key
|
2018-02-16 21:26:43 +01:00
|
|
|
from zerver.lib.api_test_helpers import test_update_message_edit_permission_error
|
2017-01-13 13:50:39 +01:00
|
|
|
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
|
|
|
django.setup()
|
2017-07-19 15:35:08 +02:00
|
|
|
from zerver.models import get_user, get_realm
|
2017-01-13 13:50:39 +01:00
|
|
|
|
|
|
|
|
2017-10-02 22:12:58 +02:00
|
|
|
with test_server_running(external_host='zulipdev.com:9981'):
|
2017-05-17 23:24:05 +02:00
|
|
|
email = 'iago@zulip.com' # Iago is an admin
|
2017-07-19 15:35:08 +02:00
|
|
|
realm = get_realm("zulip")
|
|
|
|
api_key = get_user(email, realm).api_key
|
2017-10-02 22:12:58 +02:00
|
|
|
site = 'http://zulip.zulipdev.com:9981'
|
2017-01-13 13:50:39 +01:00
|
|
|
|
|
|
|
client = Client(
|
|
|
|
email=email,
|
|
|
|
api_key=api_key,
|
|
|
|
site=site)
|
|
|
|
|
2017-01-26 01:42:09 +01:00
|
|
|
print("Running API tests...")
|
2017-01-13 13:50:39 +01:00
|
|
|
test_the_api(client)
|
2017-01-26 01:42:09 +01:00
|
|
|
|
2018-02-16 21:26:43 +01:00
|
|
|
email = 'newbie@zulip.com' # newbie is not an admin
|
|
|
|
realm = get_realm("zulip")
|
|
|
|
api_key = get_user(email, realm).api_key
|
|
|
|
site = 'http://zulip.zulipdev.com:9981'
|
|
|
|
nonadmin_client = Client(
|
|
|
|
email=email,
|
|
|
|
api_key=api_key,
|
|
|
|
site=site
|
|
|
|
)
|
|
|
|
|
|
|
|
# Run tests that require non-admin client
|
|
|
|
test_update_message_edit_permission_error(client, nonadmin_client)
|
|
|
|
|
2018-02-06 21:04:07 +01:00
|
|
|
# Test error payloads
|
|
|
|
client = Client(
|
|
|
|
email=email,
|
|
|
|
api_key='abcedrsdfd',
|
|
|
|
site=site
|
|
|
|
)
|
|
|
|
test_invalid_api_key(client)
|
|
|
|
|
|
|
|
|
2017-01-26 01:42:09 +01:00
|
|
|
print("API tests passed!")
|