Skip to content

Commit

Permalink
update dependencies, start updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Apr 7, 2021
1 parent dcea7d6 commit c231001
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 217 deletions.
85 changes: 31 additions & 54 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,34 @@
#
# pip-compile --output-file=requirements-test.txt test-requirements.in
#
aiohttp==3.7.4
# via -r test-requirements.in
async-timeout==3.0.1
# via aiohttp
asynctest==0.13.0
# via -r test-requirements.in
attrs==20.1.0
# via
# aiohttp
# pytest
chardet==3.0.4
# via aiohttp
coverage==5.2.1
# via pytest-cov
idna==2.10
# via yarl
iniconfig==1.0.1
# via pytest
mock==4.0.2
# via -r test-requirements.in
more-itertools==8.4.0
# via pytest
multidict==4.7.6
# via
# aiohttp
# yarl
packaging==20.4
# via pytest
pluggy==0.13.1
# via pytest
py==1.9.0
# via pytest
pyparsing==2.4.7
# via packaging
pytest-asyncio==0.14.0
# via -r test-requirements.in
pytest-cov==2.10.1
# via -r test-requirements.in
pytest-mock==3.3.1
# via -r test-requirements.in
pytest==6.0.1
# via
# -r test-requirements.in
# pytest-asyncio
# pytest-cov
# pytest-mock
six==1.15.0
# via packaging
toml==0.10.1
# via pytest
typing-extensions==3.7.4.3
# via aiohttp
yarl==1.5.1
# via aiohttp
aiohttp==3.7.4.post0 # via -r test-requirements.in
async-timeout==3.0.1 # via aiohttp
asynctest==0.13.0 # via -r test-requirements.in
attrs==20.3.0 # via aiohttp, pytest
certifi==2020.12.5 # via httpx, requests
chardet==4.0.0 # via aiohttp, requests
coverage==5.5 # via pytest-cov
h11==0.12.0 # via httpcore
httpcore==0.12.3 # via httpx, sanic-testing
httpx==0.16.1 # via sanic-testing
idna==2.10 # via requests, yarl
iniconfig==1.1.1 # via pytest
mock==4.0.3 # via -r test-requirements.in
multidict==5.1.0 # via aiohttp, yarl
packaging==20.9 # via pytest
pluggy==0.13.1 # via pytest
py==1.10.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via -r test-requirements.in
pytest-cov==2.11.1 # via -r test-requirements.in
pytest-mock==3.5.1 # via -r test-requirements.in
pytest==6.2.2 # via -r test-requirements.in, pytest-asyncio, pytest-cov, pytest-mock
requests==2.25.1 # via -r test-requirements.in
rfc3986[idna2008]==1.4.0 # via httpx
sanic-testing==0.3.0 # via -r test-requirements.in
sniffio==1.2.0 # via httpcore, httpx
toml==0.10.2 # via pytest
typing-extensions==3.7.4.3 # via aiohttp
urllib3==1.26.4 # via requests
websockets==8.1 # via sanic-testing
yarl==1.6.3 # via aiohttp
53 changes: 23 additions & 30 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,37 @@
# pip-compile --output-file=requirements.txt setup.py
#
aiocache==0.11.1 # via synse_server (setup.py)
aiofiles==0.5.0 # via sanic
bison==0.1.2 # via synse_server (setup.py)
cachetools==4.1.1 # via google-auth
certifi==2020.6.20 # via httpx, kubernetes, requests
chardet==3.0.4 # via httpx, requests
google-auth==1.20.1 # via kubernetes
grpcio==1.31.0 # via synse-grpc, synse_server (setup.py)
h11==0.9.0 # via httpx
h2==3.2.0 # via httpx
hpack==3.0.0 # via h2
hstspreload==2020.8.25 # via httpx
aiofiles==0.6.0 # via sanic
bison==0.1.3 # via synse_server (setup.py)
cachetools==4.2.1 # via google-auth
certifi==2020.12.5 # via kubernetes, requests
chardet==4.0.0 # via requests
google-auth==1.28.0 # via kubernetes
grpcio==1.36.1 # via synse-grpc, synse_server (setup.py)
httptools==0.1.1 # via sanic
httpx==0.11.1 # via sanic
hyperframe==5.2.0 # via h2
idna==2.10 # via httpx, requests
kubernetes==11.0.0 # via synse_server (setup.py)
multidict==4.7.6 # via sanic
idna==2.10 # via requests
kubernetes==12.0.1 # via synse_server (setup.py)
multidict==5.1.0 # via sanic
oauthlib==3.1.0 # via requests-oauthlib
prometheus-client==0.8.0 # via synse_server (setup.py)
protobuf==3.13.0 # via synse-grpc
prometheus-client==0.9.0 # via synse_server (setup.py)
protobuf==3.15.6 # via synse-grpc
pyasn1-modules==0.2.8 # via google-auth
pyasn1==0.4.8 # via pyasn1-modules, rsa
python-dateutil==2.8.1 # via kubernetes
pyyaml==5.3.1 # via bison, kubernetes, synse_server (setup.py)
pyyaml==5.4.1 # via bison, kubernetes, synse_server (setup.py)
requests-oauthlib==1.3.0 # via kubernetes
requests==2.24.0 # via kubernetes, requests-oauthlib
rfc3986==1.4.0 # via httpx
rsa==4.6 # via google-auth
sanic==20.6.3 # via synse_server (setup.py)
requests==2.25.1 # via kubernetes, requests-oauthlib
rsa==4.7.2 # via google-auth
sanic-routing==0.4.2 # via sanic
sanic==21.3.2 # via synse_server (setup.py)
shortuuid==1.0.1 # via synse_server (setup.py)
six==1.15.0 # via google-auth, grpcio, kubernetes, protobuf, python-dateutil, structlog, websocket-client
sniffio==1.1.0 # via httpx
structlog==20.1.0 # via synse_server (setup.py)
six==1.15.0 # via google-auth, grpcio, kubernetes, protobuf, python-dateutil, websocket-client
structlog==21.1.0 # via synse_server (setup.py)
synse-grpc==3.1.0 # via synse_server (setup.py)
ujson==2.0.3 # via sanic
urllib3==1.25.10 # via httpx, kubernetes, requests
uvloop==0.14.0 # via sanic
websocket-client==0.57.0 # via kubernetes
ujson==4.0.2 # via sanic
urllib3==1.26.4 # via kubernetes, requests
uvloop==0.15.2 # via sanic
websocket-client==0.58.0 # via kubernetes
websockets==8.1 # via sanic, synse_server (setup.py)

# The following packages are considered to be unsafe in a requirements file:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'bison>=0.1.0',
'grpcio',
'kubernetes',
'pyyaml>=4.2b1',
'pyyaml>=5.4',
'sanic>=0.8.0',
'prometheus-client',
'shortuuid',
Expand Down
71 changes: 39 additions & 32 deletions synse_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,6 @@
logger = structlog.get_logger()


def new_app() -> Sanic:
"""Create a new instance of the Synse Server Sanic application.
Returns:
A Sanic application for Synse Server.
"""

app = Sanic(
name='synse-server',
error_handler=errors.SynseErrorHandler(),
configure_logging=False,
)

# Disable the default Sanic logo.
app.config.LOGO = None

# Register the endpoint blueprints with the application.
app.blueprint(http.core)
app.blueprint(http.v3)
app.blueprint(websocket.v3)

# Add favicon. This will add a favicon, preventing errors being logged when
# a browser hits an endpoint and can't find the icon.
app.static('/favicon.ico', '/etc/synse/static/favicon.ico')

# Register middleware with the application.
app.register_middleware(on_request, 'request')
app.register_middleware(on_response, 'response')

return app


def on_request(request: Request) -> None:
"""Middleware function that runs prior to processing a request via Sanic."""
# Generate a unique request ID and use it as a field in any logging that
Expand Down Expand Up @@ -88,3 +56,42 @@ def on_response(request: Request, response: HTTPResponse) -> None:
contextvars.unbind_contextvars(
'request_id',
)



# def new_app(name=None) -> Sanic:
# """Create a new instance of the Synse Server Sanic application.
#
# Args:
# name: Name of the application. This allows tests to create application
# instances with different names.
#
# Returns:
# A Sanic application for Synse Server.
# """

app = Sanic(
name='synse-server',
error_handler=errors.SynseErrorHandler(),
configure_logging=False,
)

# Disable the default Sanic logo.
app.config.LOGO = None

# Register the endpoint blueprints with the application.
app.blueprint(http.core)
app.blueprint(http.v3)
app.blueprint(websocket.v3)

# Add favicon. This will add a favicon, preventing errors being logged when
# a browser hits an endpoint and can't find the icon.
app.static('/favicon.ico', '/etc/synse/static/favicon.ico')

# Register middleware with the application.
app.register_middleware(on_request, 'request')
app.register_middleware(on_response, 'response')

# return app


2 changes: 1 addition & 1 deletion synse_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, host: str = None, port: int = 5000, log_header: bool = True):
self._initialize()

# With setup complete, we can initialize a new Sanic application.
self.app = app.new_app()
self.app = app.app

# The Sanic asyncio server
self.server = None
Expand Down
4 changes: 3 additions & 1 deletion test-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ mock
pytest
pytest-asyncio
pytest-cov
pytest-mock
pytest-mock
requests
sanic-testing
Loading

0 comments on commit c231001

Please sign in to comment.