chaoss / grimoirelab-bestiary

GNU General Public License v3.0
3 stars 9 forks source link

Implement API methods to create and remove data sets #84

Closed jjmerchante closed 2 years ago

jjmerchante commented 2 years ago

This Pull request includes the following changes:

Every change has its related tests.

jjmerchante commented 2 years ago

I have a question about the JSONField. I have included some tests that now fail, but I don't understand why.

As far as I understand there is a function to serialize the JSONFields and it is registered with @convert_django_field.register(JSONField). It works for Operation.args but it doesn't work for Dataset.filters by default. I don't know what I'm missing.

sduenas commented 2 years ago

I have a question about the JSONField. I have included some tests that now fail, but I don't understand why.

As far as I understand there is a function to serialize the JSONFields and it is registered with @convert_django_field.register(JSONField). It works for Operation.args but it doesn't work for Dataset.filters by default. I don't know what I'm missing.

What's the error you are getting?

jjmerchante commented 2 years ago

Debugging, the error is returned here:

executed = client.execute(BT_DATASETS_QUERY,
                          context_value=self.context_value)
datasets = executed['data']['datasets']['entities']
{'errors': [{'message': 'the JSON object must be str, bytes or bytearray, not dict'}], 'data': {'datasets': {'entities': [None]}}}

and debugging a bit more it raises here: https://github.com/chaoss/grimoirelab-bestiary/blob/unicorn/bestiary/core/schema.py#L99

The value is a dictionary and it expects an string. I see that in Operations the JSONField is stored as a string instead of a dictionary: https://github.com/chaoss/grimoirelab-bestiary/blob/3e26e65583ab65ccddf795d52b290922bae5985a/bestiary/core/log.py#L139, so I guess I should do the same for the Dataset (store filters as string in the JSONField)