2017-01-13 13:50:39 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import print_function
|
2017-02-05 21:24:28 +01:00
|
|
|
from __future__ import absolute_import
|
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-01-13 13:50:39 +01:00
|
|
|
TOOLS_DIR = os.path.dirname(__file__)
|
|
|
|
ROOT_DIR = os.path.dirname(TOOLS_DIR)
|
|
|
|
sys.path.insert(0, ROOT_DIR)
|
|
|
|
|
|
|
|
from zulip import Client
|
|
|
|
|
|
|
|
from tools.lib.test_server import test_server_running
|
|
|
|
from tools.lib.api_tests import test_the_api
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
with test_server_running():
|
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-01-13 13:50:39 +01:00
|
|
|
site = 'http://127.0.0.1:9981'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
print("API tests passed!")
|