Ejemplo n.º 1
0
def test_ts_datasource_model_init_with_values():
    test_values = {
        "active": False,
        "name": "jaa",
        "file_path": "/dev/random/",
        "type": "a type",
        "pattern": "line pattern?",
    }
    ts_datasources = models.TimeseriesDatasourceModel()
    item = ts_datasources._create_item(**test_values)
    for k, v in list(test_values.items()):
        itemvalue = getattr(item, k).value
        assert itemvalue == v
Ejemplo n.º 2
0
def test_ts_datasource_model_reset():
    test_values = {
        "active": False,
        "name": "jaa",
        "file_path": THREEDI_RESULTS_PATH,
        "type": "netcdf-groundwater",
        "pattern": "line pattern?",
    }
    ts_datasources = models.TimeseriesDatasourceModel()
    ts_datasources.insertRows([test_values])
    assert ts_datasources.rowCount() == 1
    ts_datasources.reset()
    assert ts_datasources.rowCount() == 0
Ejemplo n.º 3
0
def test_ts_datasource_model_threedi_results():
    """Test the datasource() method with netcdf file."""
    test_values = {
        "active": False,
        "name": "jaa",
        "file_path": THREEDI_RESULTS_PATH,
        "type": "netcdf-groundwater",
        "pattern": "line pattern?",
    }
    ts_datasources = models.TimeseriesDatasourceModel()
    item = ts_datasources._create_item(**test_values)
    threedi_result = item.threedi_result()
    assert isinstance(threedi_result, ThreediResult)
    assert threedi_result.datasource
Ejemplo n.º 4
0
def test_ts_datasource_model_field_models():
    """Smoke test of the three helper methods on the Fields object."""
    test_values = {
        "active": False,
        "name": "jaa",
        "file_path": THREEDI_RESULTS_PATH,
        "type": "netcdf-groundwater",
        "pattern": "line pattern?",
    }
    ts_datasources = models.TimeseriesDatasourceModel()
    ts_datasources.insertRows([test_values])
    assert ts_datasources.rows[0].threedi_result()
    assert ts_datasources.rows[0].sqlite_gridadmin_filepath()
    with mock.patch(
            "ThreeDiToolbox.tool_result_selection.models.StatusProgressBar"):
        assert ts_datasources.rows[0].get_result_layers()
Ejemplo n.º 5
0
def test_ts_datasource_model_barfs_on_unkown_type():
    """Smoke test of the three helper methods on the Fields object."""
    test_values = {
        "active": False,
        "name": "jaa",
        "file_path": THREEDI_RESULTS_PATH,
        "type": "reinout-shoppinglist",
        "pattern": "line pattern?",
    }
    ts_datasources = models.TimeseriesDatasourceModel()
    ts_datasources.insertRows([test_values])
    with mock.patch("ThreeDiToolbox.tool_result_selection.models.pop_up_info"
                    ) as mock_pop_up_info:
        with pytest.raises(AssertionError):
            # Barfs on the unknown datasource_type
            ts_datasources.rows[0].datasource_layer_helper
            assert mock_pop_up_info.called
Ejemplo n.º 6
0
def test_get_line_pattern():
    ts_datasources = models.TimeseriesDatasourceModel()
    for i in range(8):
        test_values = {
            "active": False,
            "name": "jaa",
            "file_path": THREEDI_RESULTS_PATH,
            "type": "netcdf-groundwater",
            # Note: pattern is not set, we want the default.
        }
        ts_datasources.insertRows([test_values])
    first_pattern = ts_datasources.rows[0].pattern.value
    second_pattern = ts_datasources.rows[1].pattern.value
    last_pattern = ts_datasources.rows[-1].pattern.value
    # Different styles, if possible:
    assert first_pattern != second_pattern
    # If they're all used up, use the first one as fallback.
    assert first_pattern == last_pattern
def test_result_selection_tool_init():
    iface = mock.Mock()
    ts_datasources = models.TimeseriesDatasourceModel()
    result_selection_tool = result_selection.ThreeDiResultSelection(
        iface, ts_datasources)
    assert "icon_add_datasource.png" in result_selection_tool.icon_path