Make sure we don't use DataLayer.settings by reference

This commit is contained in:
Yohan Boniface 2023-10-06 22:25:56 +02:00
parent d0b01e774c
commit de6c9f3b84

View file

@ -1,4 +1,5 @@
import json
import copy
import factory
from django.contrib.auth import get_user_model
@ -102,13 +103,16 @@ class DataLayerFactory(factory.django.DjangoModelFactory):
name = "test datalayer"
description = "test description"
display_on_load = True
settings = {"displayOnLoad": True, "browsable": True, "name": name}
settings = factory.Dict({"displayOnLoad": True, "browsable": True, "name": name})
@classmethod
def _adjust_kwargs(cls, **kwargs):
data = kwargs.pop("data", DATALAYER_DATA).copy()
data = kwargs.pop("data", copy.deepcopy(DATALAYER_DATA))
kwargs["settings"]["name"] = kwargs["name"]
data["_umap_options"] = kwargs["settings"]
data["_umap_options"] = {
**DataLayerFactory.settings._defaults,
**kwargs["settings"],
}
kwargs["geojson"] = ContentFile(json.dumps(data), "foo.json")
return kwargs