| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- from pathlib import Path
- from fastapi.testclient import TestClient
- from mocka.main import get_application
- from mocka.configuration import Configuration, Server
- client = TestClient(get_application(Configuration(Server("localhost", 8585))))
- # def test_read_main():
- # response = client.get("/", headers={})
- # assert response.status_code == 201
- # assert response.json() == {
- # "port": "ok",
- # "output": {
- # "artefact_1": "<uri>",
- # "artefact_2": "<uri>",
- # }
- # }
- def test_post_main():
- file_path = Path(__file__).parent.parent / Path("data/mock_requirements.txt")
- requirements = file_path.read_text()
- mock_input = {
- "ctrl": "cin",
- "input": {
- "din": {
- "type": "inline",
- "content": requirements,
- "encoding": "text/plain"
- }
- }
- }
- response = client.post("/", json=mock_input)
- assert response.status_code == 200
- assert response.json() == {
- "ctrl": "ok",
- "output": {
- "dout": {
- "type": "inline",
- "content": requirements + "\n\nChecked!",
- "name": file_path.name,
- "encoding": "text/plain"
- }
- }
- }
|