示例#1
0
def test_no_obs_error(facade, monkeypatch):
    obs_mock = pd.DataFrame()
    obs_loader = Mock(return_value=obs_mock)
    response_loader = Mock(return_value=pd.DataFrame([1, 2]))
    monkeypatch.setattr(loader, "_create_multi_index", MagicMock(return_value=[1]))
    facade.get_impl_type_name_for_obs_key.return_value = "SUMMARY_OBS"
    with pytest.raises(loader.ObservationError):
        loader._extract_data(
            facade,
            "some_key",
            "a_random_name",
            response_loader,
            obs_loader,
            "SUMMARY_OBS",
        )
示例#2
0
def test_multiple_obs_types(facade, monkeypatch):
    facade.get_impl_type_name_for_obs_key.side_effect = [
        "SUMMARY_OBS",
        "SUMMARY_OBS",
        "BLOCK_OBS",
    ]
    with pytest.raises(
            loader.ObservationError,
            match=r"Found: \['SUMMARY_OBS', 'SUMMARY_OBS', 'BLOCK_OBS'\]",
    ):
        loader._extract_data(
            facade,
            ["some_summary_key", "another_summary_key", "block_key"],
            "a_random_name",
            Mock(),
            Mock(),
            "SUMMARY_OBS",
        )
示例#3
0
def test_different_data_key(facade):
    facade.get_impl_type_name_for_obs_key.return_value = "SUMMARY_OBS"
    facade.get_data_key_for_obs_key.side_effect = [
        "data_key",
        "another_data_key",
        "data_key",
    ]
    with pytest.raises(
            loader.ObservationError,
            match=r"found: \['data_key', 'another_data_key', 'data_key'\]",
    ):
        loader._extract_data(
            facade,
            ["obs_1", "obs_2", "obs_3"],
            "a_random_name",
            Mock(),
            Mock(),
            "SUMMARY_OBS",
        )