Skip to content

Commit

Permalink
feat: add taxhub route that serve status symbologies
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Sep 26, 2024
1 parent b88a455 commit bdec803
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
55 changes: 55 additions & 0 deletions apptax/taxonomie/routesbdcstatuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,61 @@ def get_status_lists_values(status_type=None):
return [d.as_dict(fields=("code_statut", "label_statut", "display")) for d in data]


@adresses.route("/status_symbologies", methods=["GET"])
def get_status_symbologies():
"""
Retourne un json décrivant la symbologie associée aux status.

:returns: un json de la structure suivante
{
symbologies: [
{
types: ["Type 1", "<Type 2>", etc.],
values: {
[value]: {
color: "color"
}
}
},
...
{
types: ["LRM", "LRE", "LRN", "LRR"],
values: {
LC: {
color: "#78b74a"
},
VU: {
color: "#ffed00"
}
}
}
]
}
"""
return jsonify(
{
"symbologies": [
{
"types": ["LRM", "LRE", "LRN", "LRR"],
"values": {
"EX": {"color": "#000000"},
"EW": {"color": "#3d1951"},
"RE": {"color": "#5a1a63"},
"CR": {"color": "#d3001b"},
"EN": {"color": "#fbbf00"},
"VU": {"color": "#ffed00"},
"NT": {"color": "#fbf2ca"},
"LC": {"color": "#78b74a"},
"DD": {"color": "#d3d4d5"},
"NA": {"color": "#919291"},
"NE": {"color": "#ffffff"},
},
}
]
}
)


@adresses.route("/status_types", methods=["GET"])
@json_resp
def get_status_types():
Expand Down
33 changes: 33 additions & 0 deletions apptax/tests/test_bdcstatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest
from flask import url_for

DEFAULT_STATUS_SYMBOLOGY = {
"symbologies": [
{
"types": ["LRM", "LRE", "LRN", "LRR"],
"values": {
"EX": {"color": "#000000"},
"EW": {"color": "#3d1951"},
"RE": {"color": "#5a1a63"},
"CR": {"color": "#d3001b"},
"EN": {"color": "#fbbf00"},
"VU": {"color": "#ffed00"},
"NT": {"color": "#fbf2ca"},
"LC": {"color": "#78b74a"},
"DD": {"color": "#d3d4d5"},
"NA": {"color": "#919291"},
"NE": {"color": "#ffffff"},
},
}
]
}


@pytest.mark.usefixtures("client_class")
class TestApiBdcStatus:
def test_status_symbologies(self):
response = self.client.get(
url_for("bdc_status.get_status_symbologies"),
)
assert response.status_code == 200
assert response.json == DEFAULT_STATUS_SYMBOLOGY

0 comments on commit bdec803

Please sign in to comment.