Преглед на файлове

Fixing lack of output artifact.

Lucas Albertins преди 2 години
родител
ревизия
33e08e4702
променени са 1 файла, в които са добавени 28 реда и са изтрити 12 реда
  1. 28 12
      mocka/router.py

+ 28 - 12
mocka/router.py

@@ -6,7 +6,8 @@ import arklog
 from fastapi import APIRouter, Query, Request, Response
 from fastapi.responses import JSONResponse
 import asyncio
-
+from io import StringIO
+import csv
 
 class MockRouter(APIRouter):
     """"""
@@ -32,22 +33,37 @@ class MockRouter(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 / Path("data/mock_requirements.txt")
             requirements = file_path.read_text() + "\n\nChecked!"
             mime = magic.Magic(mime=True).from_file(file_path)
             await asyncio.sleep(3)
-            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
+            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: