# Path: yams_api/api.py
# def validation_error(e):
# def bad_request_error(e):
# def not_found_error(e):
# def status():
# def set_endpoints():
# def endpoints(url_filter=None):
# 
# Path: yams/app.py
# API_HOST = "%s://%s:%s" % (PREFERRED_URL_SCHEME, API.LISTEN_HOST, API.LISTEN_PORT)
# def load_user():
# def append_to_navigation_menu(dictionary):
# def inject_site_name():
# def inject_navbar(navigation_dict=navigation_dictionary_list):
# def to_json_valid_or_error(data_dict):
# def to_bootstrap_size(size):
# def yams_status():
# def yams_whoami():
# def index():
# 
# Path: config.py
# class APP:
# 
#     LISTEN_HOST = chain_load_setting("APP_HOST", "YAMS_APP_HOST", "127.0.0.1")
#     LISTEN_PORT = chain_load_setting("APP_PORT", "YAMS_APP_PORT", default=1110)
#     LISTEN_URL = "http://%s:%s" % (LISTEN_HOST, LISTEN_PORT)
# 
#     DEBUG = chain_load_setting("DEBUG", "YAMS_DEBUG", True)
#     DEBUG_FRONTEND = chain_load_setting("DEBUG_FRONTEND", "YAMS_DEBUG_FRONTEND", False)
# 
#     API_VERSION_CORE = chain_load_setting("API_VERSION_CORE", "YAMS_API_VERSION_CORE", default="dev")
#     API_VERSION_PLUGINS = chain_load_setting("API_VERSION_PLUGINS", "YAMS_API_VERSION_PLUGINS", default="dev")
# 
#     default_datadir = os.path.join(basedir, "yams_api", "data")
#     DATADIR = chain_load_setting("API_DATADIR", "YAMS_API_DATADIR", default=default_datadir)
# 
#     default_database = "sqlite:///" + os.path.join(basedir, "yams.sqlite")
#     SQLALCHEMY_DATABASE_URI = chain_load_setting("APP_DATABASE_URI", "YAMS_APP_DATABASE_URI", default=default_database)
# 
#     SITE_NAME = chain_load_setting("APP_REBRANDING_NAME", "YAMS_REBRANDING_NAME", default="YAMS")
# 
# class API:
# 
#     LISTEN_HOST = chain_load_setting("API_HOST", "YAMS_API_HOST", "127.0.0.1")
#     LISTEN_PORT = chain_load_setting("API_PORT", "YAMS_API_PORT", default=1111)
#     LISTEN_URL = "http://%s:%s" % (LISTEN_HOST, LISTEN_PORT)
#     # ----------------------------------------- #
#     # ---- Socket API ---- #
#     LISTEN_PORT_SOCKET = chain_load_setting("API_SOCKET_PORT", "YAMS_API_SOCKET_PORT", default=1112)
# 
#     # Yield epsilon is to avoid busy-waiting.  0 denotes yielding to any ready thread.  See scheduler docs.
#     # I've found 0 to fully utilize a core, so defaults to a longer interval to save electricity.
#     YIELD_TO_READY_THREADS=0
#     SOCKET_THREAD_YIELD_EPSILON = 0.25
#     SOCKET_TIMEOUT_SECONDS = 30
#     SOCKET_RX_BUFFER_BYTES = 4096
# 
#     # ----------------------------------------- #
# 
#     DEBUG = chain_load_setting("DEBUG", "YAMS_API_DEBUG", True)
# 
#     API_VERSION_CORE = chain_load_setting("API_VERSION_CORE", "YAMS_API_VERSION_CORE", default="dev")
#     API_VERSION_PLUGINS = chain_load_setting("API_VERSION_PLUGINS", "YAMS_API_VERSION_PLUGINS", default="dev")
# 
#     default_datadir = os.path.join(basedir, "yams_api", "data")
#     DATADIR = chain_load_setting("API_DATADIR", "YAMS_API_DATADIR", default=default_datadir)
# 
#     default_database = "sqlite:///" + os.path.join(basedir, "yams_api.sqlite")
#     SQLALCHEMY_DATABASE_URI = chain_load_setting("API_DATABASE_URI", "YAMS_API_DATABASE_URI", default=default_database)
# 
# 
#     # If we have redis, we have rate limiting available
#     try:
#         r = redis.Redis()
#         r.ping()
#         USE_RATE_LIMITS = True
#     except redis.ConnectionError:
#         USE_RATE_LIMITS = False


import json
import unittest
from flask import jsonify, url_for
from yams_api import api
from yams import app
from config import APP, API



class TestAPIStatus(unittest.TestCase):

    @classmethod
    def setUpClass(cls):

# Path: yams_api/api.py
# def validation_error(e):
# def bad_request_error(e):
# def not_found_error(e):
# def status():
# def set_endpoints():
# def endpoints(url_filter=None):
# 
# Path: yams/app.py
# API_HOST = "%s://%s:%s" % (PREFERRED_URL_SCHEME, API.LISTEN_HOST, API.LISTEN_PORT)
# def load_user():
# def append_to_navigation_menu(dictionary):
# def inject_site_name():
# def inject_navbar(navigation_dict=navigation_dictionary_list):
# def to_json_valid_or_error(data_dict):
# def to_bootstrap_size(size):
# def yams_status():
# def yams_whoami():
# def index():
# 
# Path: config.py
# class APP:
# 
#     LISTEN_HOST = chain_load_setting("APP_HOST", "YAMS_APP_HOST", "127.0.0.1")
#     LISTEN_PORT = chain_load_setting("APP_PORT", "YAMS_APP_PORT", default=1110)
#     LISTEN_URL = "http://%s:%s" % (LISTEN_HOST, LISTEN_PORT)
# 
#     DEBUG = chain_load_setting("DEBUG", "YAMS_DEBUG", True)
#     DEBUG_FRONTEND = chain_load_setting("DEBUG_FRONTEND", "YAMS_DEBUG_FRONTEND", False)
# 
#     API_VERSION_CORE = chain_load_setting("API_VERSION_CORE", "YAMS_API_VERSION_CORE", default="dev")
#     API_VERSION_PLUGINS = chain_load_setting("API_VERSION_PLUGINS", "YAMS_API_VERSION_PLUGINS", default="dev")
# 
#     default_datadir = os.path.join(basedir, "yams_api", "data")
#     DATADIR = chain_load_setting("API_DATADIR", "YAMS_API_DATADIR", default=default_datadir)
# 
#     default_database = "sqlite:///" + os.path.join(basedir, "yams.sqlite")
#     SQLALCHEMY_DATABASE_URI = chain_load_setting("APP_DATABASE_URI", "YAMS_APP_DATABASE_URI", default=default_database)
# 
#     SITE_NAME = chain_load_setting("APP_REBRANDING_NAME", "YAMS_REBRANDING_NAME", default="YAMS")
# 
# class API:
# 
#     LISTEN_HOST = chain_load_setting("API_HOST", "YAMS_API_HOST", "127.0.0.1")
#     LISTEN_PORT = chain_load_setting("API_PORT", "YAMS_API_PORT", default=1111)
#     LISTEN_URL = "http://%s:%s" % (LISTEN_HOST, LISTEN_PORT)
#     # ----------------------------------------- #
#     # ---- Socket API ---- #
#     LISTEN_PORT_SOCKET = chain_load_setting("API_SOCKET_PORT", "YAMS_API_SOCKET_PORT", default=1112)
# 
#     # Yield epsilon is to avoid busy-waiting.  0 denotes yielding to any ready thread.  See scheduler docs.
#     # I've found 0 to fully utilize a core, so defaults to a longer interval to save electricity.
#     YIELD_TO_READY_THREADS=0
#     SOCKET_THREAD_YIELD_EPSILON = 0.25
#     SOCKET_TIMEOUT_SECONDS = 30
#     SOCKET_RX_BUFFER_BYTES = 4096
# 
#     # ----------------------------------------- #
# 
#     DEBUG = chain_load_setting("DEBUG", "YAMS_API_DEBUG", True)
# 
#     API_VERSION_CORE = chain_load_setting("API_VERSION_CORE", "YAMS_API_VERSION_CORE", default="dev")
#     API_VERSION_PLUGINS = chain_load_setting("API_VERSION_PLUGINS", "YAMS_API_VERSION_PLUGINS", default="dev")
# 
#     default_datadir = os.path.join(basedir, "yams_api", "data")
#     DATADIR = chain_load_setting("API_DATADIR", "YAMS_API_DATADIR", default=default_datadir)
# 
#     default_database = "sqlite:///" + os.path.join(basedir, "yams_api.sqlite")
#     SQLALCHEMY_DATABASE_URI = chain_load_setting("API_DATABASE_URI", "YAMS_API_DATABASE_URI", default=default_database)
# 
# 
#     # If we have redis, we have rate limiting available
#     try:
#         r = redis.Redis()
#         r.ping()
#         USE_RATE_LIMITS = True
#     except redis.ConnectionError:
#         USE_RATE_LIMITS = False


# Path: tests/test_api.py
import json
import unittest
from flask import jsonify, url_for
from yams_api import api
from yams import app
from config import APP, API




class TestAPIStatus(unittest.TestCase):

    @classmethod
    def setUpClass(cls):

        api.config['SERVER_NAME'] = "%s:%s" % (API.LISTEN_HOST, API.LISTEN_PORT)