-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): fastapi plugins for UT #540
- rename lib name for nameing collision - testcase for ut close #540
- Loading branch information
Showing
16 changed files
with
187 additions
and
86 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
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import unittest | ||
|
||
|
||
from pinpointPy.Fastapi import PinPointMiddleWare | ||
from pinpointPy import set_agent | ||
|
||
from starlette_context.middleware import RawContextMiddleware | ||
from starlette.middleware import Middleware | ||
|
||
from fastapi import FastAPI | ||
from fastapi.testclient import TestClient | ||
from fastapi import Request | ||
|
||
|
||
class Test_UT(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
middlewares = [ | ||
Middleware( | ||
RawContextMiddleware | ||
), | ||
Middleware(PinPointMiddleWare) | ||
] | ||
app = FastAPI(title='pinpointpy test', middleware=middlewares) | ||
set_agent("cd.dev.test.py", "cd.dev.test.py", | ||
'tcp:dev-collector:9999', -1) | ||
|
||
@app.get("/cluster/{name}") | ||
async def read_main(name, request: Request): | ||
return {"msg": f"Hello World,{name}"} | ||
|
||
self.app = app | ||
self.client = TestClient(app) | ||
|
||
def test_request_example(self): | ||
response = self.client.get("/cluster/abc") | ||
assert "ut" in response.headers | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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.