Exemplo n.º 1
0
 def test_default_routes(self, tmpdir):
     routes = [
         {
             "path": "/route1",
             "responses": [
                 {
                     "body": "response1"
                 }
             ]
         },
         {
             "path": "/route2",
             "responses": [
                 {
                     "body": "response2"
                 }
             ]
         }
     ]
     routes_file = tmpdir.join('test.json')
     routes_file.write(json.dumps(routes))
     config = Config(routes_path=routes_file)
     assert config.DEFAULT_ROUTES == routes
Exemplo n.º 2
0
 def test_user_defined_routes_path_takes_precedence(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_ROUTES', '/test1.json')
     config = Config(routes_path='/test2.json')
     assert config.ROUTES_PATH == Path('/test2.json')
Exemplo n.º 3
0
 def test_user_defined_routes_path(self):
     config = Config(routes_path='/path.json')
     assert config.ROUTES_PATH == Path('/path.json')
Exemplo n.º 4
0
 def test_default_routes_path(self):
     config = Config()
     assert config.ROUTES_PATH is None
Exemplo n.º 5
0
 def test_routes_path_from_env(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_ROUTES', '/test.json')
     config = Config()
     assert config.ROUTES_PATH == Path('/test.json')
Exemplo n.º 6
0
 def test_user_defined_url_prefix_takes_precedence(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_INTERNAL_PREFIX', '/test')
     config = Config(internal_prefix='/api')
     assert config.INTERNAL_PREFIX == '/api'
Exemplo n.º 7
0
def run(port: int, prefix: str, routes: str) -> None:
    """Start local Trickster app."""
    config = Config(internal_prefix=prefix, port=port, routes_path=routes)
    app = ApiApp(config)
    app.run()
Exemplo n.º 8
0
 def test_coalesce(self):
     config = Config()
     assert config._coalesce(None, None, 1) == 1
Exemplo n.º 9
0
 def test_default_url_prefix(self):
     config = Config()
     assert config.INTERNAL_PREFIX == Config.DEFAULT_INTERNAL_PREFIX
Exemplo n.º 10
0
 def test_user_defined_port_takes_precedence(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_PORT', '54321')
     config = Config(port=12345)
     assert config.PORT == 12345
Exemplo n.º 11
0
 def test_port_from_env(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_PORT', '54321')
     config = Config()
     assert config.PORT == 54321
Exemplo n.º 12
0
 def test_user_defined_port(self):
     config = Config(port=12345)
     assert config.PORT == 12345
Exemplo n.º 13
0
 def test_coalesce_no_arguments(self):
     config = Config()
     assert config._coalesce() is None
Exemplo n.º 14
0
 def test_default_port(self):
     config = Config()
     assert config.PORT == Config.DEFAULT_PORT
Exemplo n.º 15
0
def config():
    return Config()
Exemplo n.º 16
0
 def test_default_routes_empty(self):
     config = Config()
     assert config.DEFAULT_ROUTES == []
Exemplo n.º 17
0
 def test_user_defined_url_prefix(self):
     config = Config(internal_prefix='/api')
     assert config.INTERNAL_PREFIX == '/api'
Exemplo n.º 18
0
 def test_url_prefix_from_env(self, monkeypatch):
     monkeypatch.setenv('TRICKSTER_INTERNAL_PREFIX', '/test')
     config = Config()
     assert config.INTERNAL_PREFIX == '/test'
Exemplo n.º 19
0
 def test_coalesce_all_none(self):
     config = Config()
     assert config._coalesce(None, None, None) is None
Exemplo n.º 20
0
"""Initialization of API app."""

from trickster.api_app import ApiApp
from trickster.config import Config

app = ApiApp(Config())