mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 09:58:06 +00:00
Previously these tests required you to run them with the root of the Zulip repository as the current working directory, just due to sloppiness. We clean this up, while also making the path handling more consistent and involving less fragile code. Fixes #4169.
41 lines
963 B
Python
Executable File
41 lines
963 B
Python
Executable File
#!/usr/bin/env python3
|
|
from __future__ import print_function
|
|
from __future__ import absolute_import
|
|
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 tools.lib.api_tests import test_the_api
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
|
django.setup()
|
|
from zerver.models import get_user, get_realm
|
|
|
|
|
|
with test_server_running():
|
|
email = 'iago@zulip.com' # Iago is an admin
|
|
realm = get_realm("zulip")
|
|
api_key = get_user(email, realm).api_key
|
|
site = 'http://127.0.0.1:9981'
|
|
|
|
client = Client(
|
|
email=email,
|
|
api_key=api_key,
|
|
site=site)
|
|
|
|
print("Running API tests...")
|
|
test_the_api(client)
|
|
|
|
print("API tests passed!")
|