|
|
@@ -5,6 +5,9 @@ import magic
|
|
|
import arklog
|
|
|
from fastapi import APIRouter, Query, Request, Response
|
|
|
from fastapi.responses import JSONResponse
|
|
|
+import asyncio
|
|
|
+from io import StringIO
|
|
|
+import csv
|
|
|
|
|
|
|
|
|
class ExampleRouter(APIRouter):
|
|
|
@@ -31,21 +34,37 @@ class ExampleRouter(APIRouter):
|
|
|
control = body.get("ctrl")
|
|
|
arklog.debug(control)
|
|
|
content = body.get("input").get("din").get("content")
|
|
|
+ f = StringIO(content)
|
|
|
+ reader = csv.reader(f, delimiter=',')
|
|
|
file_path = Path(__file__).parent.parent.parent / Path("data/mock_requirements.txt")
|
|
|
requirements = file_path.read_text() + "\n\nChecked!"
|
|
|
mime = magic.Magic(mime=True).from_file(file_path)
|
|
|
- assert content + "\n\nChecked!" == requirements
|
|
|
- return JSONResponse(status_code=200, content={
|
|
|
- "ctrl": "ok",
|
|
|
- "output": {
|
|
|
- "dout": {
|
|
|
- "type": "inline",
|
|
|
- "content": requirements,
|
|
|
- "name": file_path.name,
|
|
|
- "encoding": mime
|
|
|
+ await asyncio.sleep(3)
|
|
|
+ if ((list(reader)[5][1]) == '0.0004'):
|
|
|
+ return JSONResponse(status_code=200, content={
|
|
|
+ "ctrl": "ok",
|
|
|
+ "output": {
|
|
|
+ "dout": {
|
|
|
+ "type": "inline",
|
|
|
+ "content": requirements,
|
|
|
+ "name": file_path.name,
|
|
|
+ "encoding": mime
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ else:
|
|
|
+ return JSONResponse(status_code=200, content={
|
|
|
+ "ctrl": "notOk",
|
|
|
+ "output": {
|
|
|
+ "dout": {
|
|
|
+ "type": "inline",
|
|
|
+ "content": requirements,
|
|
|
+ "name": file_path.name,
|
|
|
+ "encoding": mime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
@self.put("/")
|
|
|
async def root_put_mock(request: Request, query: str | None = Query(None)) -> Response:
|