async def test_plugin_configuration_use_pk(ds): config = await check_config({"name_field": "name"}, ds.get_database("test"), "dogs") assert config["name_field"] == "name" assert config["id_field"] == "id" assert config["type_default"] == [{ "name": "Object", "id": "object", }] assert "type_field" not in config
async def test_plugin_configuration_use_type_default_incorrect(ds): with pytest.raises(ReconcileError, match="type_default should"): config = await check_config( { "name_field": "name", "id_field": "id", "type_default": "dog", }, ds.get_database("test"), "dogs", )
async def test_view_url_no_id(ds): with pytest.raises(ReconcileError, match="View URL must contain {{id}}"): config = await check_config( { "name_field": "name", "id_field": "id", "view_url": "https://example.com/", }, ds.get_database("test"), "dogs", )
async def test_view_url_set(ds): config = await check_config( { "name_field": "name", "id_field": "id", "view_url": "https://example.com/{{id}}", }, ds.get_database("test"), "dogs", ) assert config["view_url"] == "https://example.com/{{id}}"
async def test_plugin_configuration_use_fts_table(ds): config = await check_config( { "name_field": "name", "id_field": "id", "type_default": [{ "name": "Dog", "id": "dog", }], }, ds.get_database("test"), "dogs", ) assert config["fts_table"] is None
async def test_plugin_configuration_use_type_field(ds): config = await check_config( { "name_field": "name", "id_field": "id", "type_field": [{ "name": "Status", "id": "status", }], }, ds.get_database("test"), "dogs", ) assert config["name_field"] == "name" assert config["id_field"] == "id" assert config["type_field"] == [{ "name": "Status", "id": "status", }] assert "type_default" not in config
async def test_plugin_configuration_table_not_found(ds): with pytest.raises(NotFound, match="Table not found: test"): config = await check_config({"name_field": "name"}, ds.get_database("test"), "test")
async def test_plugin_configuration_no_name(ds): with pytest.raises( ReconcileError, match="Name field must be defined to activate reconciliation"): config = await check_config({"id_field": "id"}, ds.get_database("test"), "dogs")
async def test_plugin_configuration_missing(ds): with pytest.raises(NotFound, match="datasette-reconcile not configured .*"): config = await check_config({}, ds.get_database("test"), "dogs")