Exemplo n.º 1
0
def test_can_create_output_products(sample_stats_config, mock_index):
    # GIVEN: A simple stats app
    stats_app = StatsApp(config=sample_stats_config)
    stats_app.output_products = _SAMPLE_OUTPUTS_SPEC

    # WHEN: I call configure_outputs()
    output_prods = stats_app.configure_outputs(mock_index)

    # THEN: I should receive an appropriately configured output product
    assert len(output_prods) == 1
    fake_output = output_prods['fake_output']
    assert isinstance(fake_output, OutputProduct)
    assert fake_output.name == 'fake_output'
    assert fake_output.stat_name == 'simple'
    assert isinstance(fake_output.statistic, ReducingXarrayStatistic)

    # TODO: Check output product is created
    # Based on the source product's measurements
    mock_index.products.get_by_name.assert_called_with('fake_source_product')
Exemplo n.º 2
0
def test_create_trivial_stats_app():
    stats_app = StatsApp()
    assert stats_app is not None
    with pytest.raises(Exception):
        stats_app.validate()
Exemplo n.º 3
0
def test_raises_error_on_no_sources(sample_stats_config):
    sample_stats_config['sources'] = []
    stats_app = StatsApp.from_configuration_file(config=sample_stats_config)

    with pytest.raises(StatsConfigurationError):
        stats_app.validate()
Exemplo n.º 4
0
def test_raises_error_on_invalid_driver(sample_stats_config):
    sample_stats_config['storage']['driver'] = 'foo'

    with pytest.raises(StatsConfigurationError):
        StatsApp.from_configuration_file(sample_stats_config)
Exemplo n.º 5
0
def test_create_and_validate_stats_app(sample_stats_config):
    stats_app = StatsApp.from_configuration_file(config=sample_stats_config)
    assert stats_app is not None
    stats_app.validate()
Exemplo n.º 6
0
def create_app_with_products(sample_stats_config, mock_index):
    stats_app = StatsApp.from_configuration_file(config=sample_stats_config)
    stats_app.index = mock_index
    stats_app.output_products = _SAMPLE_OUTPUTS_SPEC
    output_prods = stats_app.configure_outputs()
    return stats_app, output_prods
Exemplo n.º 7
0
def test_raises_error_on_no_sources(sample_stats_config):
    sample_stats_config['sources'] = []

    with pytest.raises(StatsConfigurationError):
        stats_app = StatsApp(config=sample_stats_config)