-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wujiasheng03
committed
Apr 15, 2024
1 parent
a19a25a
commit 4b55947
Showing
19 changed files
with
179 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
from lyrebird import application | ||
from lyrebird.mock import context | ||
|
||
SERVER_NAMES = ['event', 'log', 'mock', 'task', 'checker', 'db', 'plugin'] | ||
|
||
@pytest.fixture(scope='module', autouse=True) | ||
def setup_and_teardown_environment(): | ||
bak_server = {} | ||
for server in SERVER_NAMES: | ||
bak_server[server] = application.server.get(server) | ||
bak_reporter = application.reporter | ||
bak_cm = application._cm | ||
bak_config = application.config | ||
bak_encoder_decoder = application.encoders_decoders | ||
bak_on_request = application.on_request | ||
bak_on_request_upstream = application.on_request_upstream | ||
bak_on_response = application.on_response | ||
bak_on_response_upstream = application.on_response_upstream | ||
bak_socketio = context.application.socket_io | ||
bak_dm = context.application.data_manager | ||
|
||
yield | ||
|
||
for server in SERVER_NAMES: | ||
if bak_server[server] is None and server in application.server: | ||
del application.server[server] | ||
elif bak_server[server] is not None: | ||
application.server[server] = bak_server[server] | ||
application.reporter = bak_reporter | ||
application._cm = bak_cm | ||
application.config = bak_config | ||
application.encoders_decoders = bak_encoder_decoder | ||
application.on_request = bak_on_request | ||
application.on_request_upstream = bak_on_request_upstream | ||
application.on_response = bak_on_response | ||
application.on_response_upstream = bak_on_response_upstream | ||
context.application.socket_io = bak_socketio | ||
context.application.data_manager = bak_dm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.