forked from python-discord/site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
42 lines (30 loc) · 1.41 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
from flask import Blueprint
from flask_testing import TestCase
os.environ["BOT_API_KEY"] = "abcdefg" # This is a constant, must be done first
os.environ["PAPERTRAIL_ADDRESS"] = 'localhost' # satisfies coverage
os.environ["DATADOG_ADDRESS"] = 'localhost' # satisfies coverage
if "FLASK_DEBUG" in os.environ:
del os.environ["FLASK_DEBUG"] # Some unit tests fail if this is set
from app import manager
from gunicorn_config import _when_ready as when_ready
when_ready()
manager.app.tests_blueprint = Blueprint("tests", __name__)
manager.load_views(manager.app.tests_blueprint, "pysite/views/tests")
manager.app.register_blueprint(manager.app.tests_blueprint)
app = manager.app
app.config["WTF_CSRF_CHECK_DEFAULT"] = False
class SiteTest(TestCase):
""" Extend TestCase with flask app instantiation """
def create_app(self):
""" Add flask app configuration settings """
server_name = 'pytest.local'
app.config['TESTING'] = True
app.config['LIVESERVER_TIMEOUT'] = 10
app.config['SERVER_NAME'] = server_name
app.config['API_SUBDOMAIN'] = f'http://api.{server_name}'
app.config['STAFF_SUBDOMAIN'] = f'http://staff.{server_name}'
app.config['WIKI_SUBDOMAIN'] = f'http://wiki.{server_name}'
app.config['TEST_HEADER'] = {'X-API-Key': 'abcdefg', 'Content-Type': 'application/json'}
app.allow_subdomain_redirects = True
return app