def test_summary_message_vert(fix_local_data, msg_format):
    """Test syntesis message when no active alert."""
    zone = DepartmentWeatherAlert("34")
    if msg_format == "text":
        excpected_result = "Aucune alerte météo en cours."
    else:  # msg_format == "html" to avoid partial in codecov
        excpected_result = "<p>Aucune alerte météo en cours.</p>"
    assert zone.summary_message(msg_format) == excpected_result
def test_results_when_proxy_raise_error(msg_format):
    """Test behaviour when Error are raised by proxy."""
    client = VigilanceMeteoFranceProxy()

    # fake the cheksum file to simulate unreachable file
    client.URL_VIGILANCE_METEO_CHECKSUM = "file:./tests/fake_file.txt"

    zone = DepartmentWeatherAlert("2A", client)
    if msg_format == "text":
        excpected_result = "Impossible de récupérer l'information."
    else:  # msg_format == "html" to avoid partial in codecov
        excpected_result = "<p>Impossible de récupérer l'information.</p>"
    assert zone.summary_message(msg_format) == excpected_result
def test_summary_message_alerte(fix_local_data, msg_format):
    """Test synthesis message when at least one active alert"""
    zone = DepartmentWeatherAlert("2A")
    if msg_format == "text":
        excpected_result = ("Alerte météo Jaune en cours :"
                            "\n - Avalanches: Jaune"
                            "\n - Orages: Jaune"
                            "\n - Pluie-inondation: Jaune"
                            "\n - Vagues-submersion: Jaune")
    else:  # msg_format == "html" to avoid partial in codecov
        excpected_result = ("<p>Alerte météo Jaune en cours :</p><ul>"
                            "<li>Avalanches: Jaune</li>"
                            "<li>Orages: Jaune</li>"
                            "<li>Pluie-inondation: Jaune</li>"
                            "<li>Vagues-submersion: Jaune</li></ul>")
    assert zone.summary_message(msg_format) == excpected_result
def test_summary_message_error(fix_local_data):
    """Test if we call summary_message method with a wrong parameter value."""
    zone = DepartmentWeatherAlert("32")
    with pytest.raises(ValueError, match=r"msg_format .*"):
        zone.summary_message("wrong_format")