Beispiel #1
0
def text_legend_config_validators():
    """Testting validators of LegendConfig object."""
    legend_config = LegendConfig()

    with pytest.raises(ValidationError):
        legend_config.colors = "red"

    with pytest.raises(ValidationError):
        legend_config.colors = 255

    legend_config.min = -10
    assert legend_config.min == -10

    with pytest.raises(ValidationError):
        legend_config.max = -20

    with pytest.raises(ValidationError):
        legend_config.min = 'less'

    with pytest.raises(ValidationError):
        legend_config.max = 'more'

    with pytest.raises(ValidationError):
        legend_config.orientation = 'up'

    with pytest.raises(ValidationError):
        legend_config.width = 200

    with pytest.raises(ValidationError):
        legend_config.height == 500

    with pytest.raises(ValidationError):
        legend_config.position = (0, 5, 4)

    with pytest.raises(ValidationError):
        legend_config.color_count = 25

    with pytest.raises(ValidationError):
        legend_config.label_count = 26

    with pytest.raises(ValidationError):
        legend_config.decimal_count = 2

    with pytest.raises(ValidationError):
        legend_config.preceding_labels = 'no'

    with pytest.raises(ValidationError):
        legend_config.label_parameters = {'color': [0, 0, 0]}

    with pytest.raises(ValidationError):
        legend_config.title_parameters = {'color': [0, 0, 0]}
Beispiel #2
0
def test_data_config_legend_parameter_validator():
    """Testing the legend parameter validator in DataConfig object."""

    # width greater than position in X direction
    legend_params = LegendConfig()
    legend_params.position = [0.5, 0.5]
    legend_params.width = 0.6
    with pytest.raises(ValidationError):
        data_config = DataConfig(identifier='Daylight-factor',
                                 object_type='grid',
                                 unit='Percentage',
                                 path='tests/assets/df_results',
                                 legend_parameters=legend_params)

    # height greater than position in Y direction
    legend_params = LegendConfig()
    legend_params.position = [0.5, 0.5]
    legend_params.height = 0.6
    with pytest.raises(ValidationError):
        data_config = DataConfig(identifier='Daylight-factor',
                                 object_type='grid',
                                 unit='Percentage',
                                 path='tests/assets/df_results',
                                 legend_parameters=legend_params)