diff --git a/apptax/taxonomie/routesbdcstatuts.py b/apptax/taxonomie/routesbdcstatuts.py index c19fe5f0..428bae29 100644 --- a/apptax/taxonomie/routesbdcstatuts.py +++ b/apptax/taxonomie/routesbdcstatuts.py @@ -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", "", 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(): diff --git a/apptax/tests/test_bdcstatus.py b/apptax/tests/test_bdcstatus.py new file mode 100644 index 00000000..599d4666 --- /dev/null +++ b/apptax/tests/test_bdcstatus.py @@ -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