def test_first_try_checksum_unreachable(fix_local_data): """Test behaviour when first checksum is unvailable.""" client = VigilanceMeteoFranceProxy() # fake the cheksum file to simulate unreachable file client.URL_VIGILANCE_METEO_CHECKSUM = "file:./tests/fake_file.txt" # should raise an error with pytest.raises(VigilanceMeteoError): client.update_data()
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_checksum_unreachable_and_bulletin_expired(fix_local_data): """Test checksum behaviour in case of error.""" # First update is OK client = VigilanceMeteoFranceProxy() client.update_data() # fake the cheksum file to simulate unreachable file client.URL_VIGILANCE_METEO_CHECKSUM = "file:./tests/fake_file.txt" # fake the date of bulletin. Make it exipred client._bulletin_date = client._bulletin_date - datetime.timedelta(days=2) # simulate 2 minutes wait client._latest_check_date = client._latest_check_date - datetime.timedelta( seconds=120) # should raise an error with pytest.raises(VigilanceMeteoError): client.update_data()
def test_checksum_unreachable_and_bulletin_valid(): """Test behaviour when checksum URL unreachable""" # First update OK client = VigilanceMeteoFranceProxy() client.update_data() first_checksum = client.checksum # fake the cheksum file to simulate unreachable file client.URL_VIGILANCE_METEO_CHECKSUM = "file:./tests/fake_file.txt" # simulate 2 minutes wait client._latest_check_date = client._latest_check_date - datetime.timedelta( seconds=120) client.update_data() # Should be no error and the value of the first update checksum assert (client.checksum, client.status) == ( first_checksum, UPDATE_STATUS_ERROR_BUT_PREVIOUS_BULLETIN_VALID, )