def test_with_configured_time_window_no_fires(self, reset_config): fm = FiresManager() Config().set({ "findmetdata": { "time_window": { "first_hour": "2016-01-04T04:00:00Z", "last_hour": "2016-01-05T13:00:00Z" } } }) expected = [{ 'start': datetime.datetime(2016, 1, 4, 4, 0, 0), 'end': datetime.datetime(2016, 1, 5, 13, 0, 0), }] assert expected == findmetdata._get_time_windows(fm)
def test_with_dispersion_and_configured_time_window_no_fires( self, reset_config): fm = FiresManager() Config().set({ "dispersion": { "start": "2014-05-29T19:00:00Z", "num_hours": 12 }, "findmetdata": { "time_window": { "first_hour": "2016-01-04T04:00:00Z", "last_hour": "2016-01-05T13:00:00Z" } } }) expected = [{ 'start': datetime.datetime(2014, 5, 29, 19, 0, 0), 'end': datetime.datetime(2014, 5, 30, 7, 0, 0), }, { 'start': datetime.datetime(2016, 1, 4, 4, 0, 0), 'end': datetime.datetime(2016, 1, 5, 13, 0, 0), }] assert expected == findmetdata._get_time_windows(fm)
def test_fire_no_activity(self, reset_config): fm = FiresManager() fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(BlueSkyConfigurationError) as e_info: findmetdata._get_time_windows(fm)
def test_no_fires(self, reset_config): fm = FiresManager() fm.load({"fires": []}) with raises(BlueSkyConfigurationError) as e_info: findmetdata._get_time_windows(fm)
def setup(self): Config().set('sev', 'plumerise', 'model') Config().set(False, 'skip_failed_fires') self.fm = FiresManager()
class TestPlumeRiseRunSev(object): def setup(self): Config().set('sev', 'plumerise', 'model') Config().set(False, 'skip_failed_fires') self.fm = FiresManager() def test_fire_no_activity(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.NO_ACTIVITY_ERROR_MSG def test_fire_missing_location_area(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCATION_AREA]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == activity.INVALID_LOCATION_MSGS[ 'specified_points'] def test_fire_missing_location_consumption(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_CONSUMPTION]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] def test_fire_missing_timeprofile(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_TIMEPROFILE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] def test_fire_missing_start_time(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_START_TIME]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] # TODO: test with invalid start time def test_fire_missing_localmet(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCALMET]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_LOCALMET_ERROR_MSG def test_no_fires(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": []}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [] def test_one_fire(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] loc1 = FIRE['activity'][0]['active_areas'][0]['specified_points'][0] loc2 = FIRE['activity'][0]['active_areas'][1]['perimeter'] assert _PR_COMPUTE_CALL_ARGS == [({ "baz": 444 }, 123), ({ "bazoo": 555 }, 3232)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}, {'frp': None}]
class TestPlumeRiseRunFeps(object): def setup(self): Config().set('feps', 'plumerise', 'model') Config().set(False, 'skip_failed_fires') self.fm = FiresManager() def test_fire_no_activity(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.NO_ACTIVITY_ERROR_MSG def test_fire_missing_location_area(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCATION_AREA]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == activity.INVALID_LOCATION_MSGS[ 'specified_points'] def test_fire_missing_location_consumption(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_CONSUMPTION]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_CONSUMPTION_ERROR_MSG def test_fire_missing_timeprofile(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_TIMEPROFILE]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_TIMEPROFILE_ERROR_MSG def test_fire_missing_start_time(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_START_TIME]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_START_TIME_ERROR_MSG # TODO: test with invalid start time def test_fire_missing_localmet(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) monkeypatch_tempfile_mkdtemp(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCALMET]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] loc1 = FIRE_MISSING_LOCALMET['activity'][0]['active_areas'][0][ 'specified_points'][0] assert _PR_COMPUTE_CALL_ARGS == [({ "foo": 1 }, { "smoldering": 123 }, loc1)] assert _PR_COMPUTE_CALL_KWARGS == [{ 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE_MISSING_LOCALMET.id) }] def test_no_fires(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": []}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] assert _PR_COMPUTE_CALL_ARGS == [] def test_one_fire(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) monkeypatch_tempfile_mkdtemp(monkeypatch) self.fm.load({"fires": [FIRE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] loc1 = FIRE['activity'][0]['active_areas'][0]['specified_points'][0] loc2 = FIRE['activity'][0]['active_areas'][1]['perimeter'] assert _PR_COMPUTE_CALL_ARGS == [({ "foo": 1 }, { "smoldering": 123 }, loc1), ({ "bar": 2 }, { "flaming": 434 }, loc2)] assert _PR_COMPUTE_CALL_KWARGS == [{ 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE.id) }, { 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE.id) }]
def setup(self): Config().set('sev', 'plumerise', 'model') self.fm = FiresManager()