Commit 05985407 authored by David Foucher's avatar David Foucher
Browse files

Merge branch 'remuneration' into 'master'

Remuneration

See merge request !3
parents 95b6296f 389af47c
Pipeline #1822 passed with stage
in 1 minute and 21 seconds
__pycache__/
.mypy_cache/
.pytest_cache/
docs/
tmp/
......
......@@ -12,6 +12,7 @@ from openapi_spec_validator import validate_spec
from trefle.config import FINANCEMENTS
from trefle.config import REMUNERATIONS
from trefle import VERSION
pytestmark = pytest.mark.asyncio
......@@ -55,6 +56,33 @@ async def test_simulate_endpoint(client):
result.raise_for_errors()
async def test_remuneration_endpoint(client):
resp = await client.get("/schema")
spec = create_spec(json.loads(resp.body))
resp = await client.post(
"/remuneration",
body={
"beneficiaire.age": 20,
"formation.region": 27,
"formation.codes_financeur": [2],
},
)
assert resp.status == HTTPStatus.OK
assert "remunerations" in json.loads(resp.body)
remunerations = json.loads(resp.body)["remunerations"]
assert remunerations
print(remunerations[0])
assert "remuneration" in remunerations[0]
assert "Version" in resp.headers
validator = ResponseValidator(spec)
request = MockRequest("http://trefle.pole-emploi.fr", "post", "/remuneration")
response = MockResponse(resp.body, resp.status.value)
result = validator.validate(request, response)
result.raise_for_errors()
async def test_simulate_endpoint_without_formation_prix_horaire(client):
resp = await client.get("/schema")
......
......@@ -4,10 +4,10 @@ from pathlib import Path
import pytest
from trefle.config import IDCC
from trefle.context import Context
from trefle import exceptions
from trefle import routine
from trefle.config import IDCC
from trefle.context import Context
@pytest.mark.asyncio
......
......@@ -37,3 +37,10 @@ def get_financements(tags=None):
for tag in tags or []:
financements = [f for f in financements if tag in f["tags"]]
return financements
def get_remunerations(tags=None):
remunerations = [config.Remuneration(f) for f in config.REMUNERATIONS]
for tag in tags or []:
remunerations = [f for f in remunerations if tag in f["tags"]]
return remunerations
......@@ -2,12 +2,16 @@ from http import HTTPStatus
from roll import HttpError, Roll
from roll.extensions import cors
import ujson as json
from . import VERSION, simulate, get_financements
from .config import FINANCEMENTS, GLOSSARY, NAF, IDCC, RAW_RULES, SCHEMA
from .debugging import data_from_lbf_url, make_scenario, SCENARIOS
from . import VERSION, get_financements, get_remunerations, simulate
from . import routine
from .config import FINANCEMENTS, GLOSSARY, IDCC, NAF, RAW_RULES, SCHEMA
from .context import Context
from .debugging import SCENARIOS, data_from_lbf_url, make_scenario