mirror of https://github.com/zulip/zulip.git
48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
|
|
# check for the venv
|
|
from lib import sanity_check
|
|
sanity_check.check_venv(__file__)
|
|
|
|
import django
|
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
sys.path.insert(0, ZULIP_PATH)
|
|
os.chdir(ZULIP_PATH)
|
|
|
|
from zulip import Client
|
|
|
|
from tools.lib.test_server import test_server_running
|
|
from zerver.lib.api_test_helpers import test_the_api, test_invalid_api_key
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
|
django.setup()
|
|
from zerver.models import get_user, get_realm
|
|
|
|
|
|
with test_server_running(external_host='zulipdev.com:9981'):
|
|
email = 'iago@zulip.com' # Iago is an admin
|
|
realm = get_realm("zulip")
|
|
api_key = get_user(email, realm).api_key
|
|
site = 'http://zulip.zulipdev.com:9981'
|
|
|
|
client = Client(
|
|
email=email,
|
|
api_key=api_key,
|
|
site=site)
|
|
|
|
print("Running API tests...")
|
|
test_the_api(client)
|
|
|
|
# Test error payloads
|
|
client = Client(
|
|
email=email,
|
|
api_key='abcedrsdfd',
|
|
site=site
|
|
)
|
|
test_invalid_api_key(client)
|
|
|
|
|
|
print("API tests passed!")
|