From 3b304e524953c8296eff57c87bd857f819add303 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 9 Oct 2023 16:55:53 +0200 Subject: [PATCH] Tests: populate settings from _umap_options when data is passed --- umap/tests/base.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/umap/tests/base.py b/umap/tests/base.py index 1076275e..5aef9e76 100644 --- a/umap/tests/base.py +++ b/umap/tests/base.py @@ -107,12 +107,17 @@ class DataLayerFactory(factory.django.DjangoModelFactory): @classmethod def _adjust_kwargs(cls, **kwargs): - data = kwargs.pop("data", copy.deepcopy(DATALAYER_DATA)) - kwargs["settings"]["name"] = kwargs["name"] - data["_umap_options"] = { - **DataLayerFactory.settings._defaults, - **kwargs["settings"], - } + if "data" in kwargs: + data = copy.deepcopy(kwargs.pop("data")) + if "settings" not in kwargs: + kwargs["settings"] = data.get("_umap_options", {}) + else: + data = DATALAYER_DATA.copy() + data["_umap_options"] = { + **DataLayerFactory.settings._defaults, + **kwargs["settings"], + } + data["_umap_options"]["name"] = kwargs["name"] kwargs["geojson"] = ContentFile(json.dumps(data), "foo.json") return kwargs