wildfish/django-gdpr-assist

object.anonymised missing and object.is_anonymised() not updating properly

HealperRasmus opened this issue · 2 comments

After trying to create a simple unit test to validate anonymisation I ran into the following issues:

Acording to the documentation the object should have a anonymised property/field but that doesn't seems to be the case.
https://django-gdpr-assist.readthedocs.io/en/latest/anonymising.html
After some debugging I found the method obj.is_anonymised() method which I guess is a replacement? In either case calling
obj.anonymise() followed directly by obj.is_anonymised() yields "False".
If I requery the model it yields True as expected.

I am running python 3.6
my unit test looks roughly like this:

def test_anonymise(self):
        address = Address( name=... )
        address.save()
        self.assertEqual(address.is_anonymised(), False)

        address.anonymise()
        self.assertEqual(address.is_anonymised(), True)

Thx for the great library. really appreciate it guys :)

Thanks for spotting the issue with the docs - yes, we recently moved the anonymised state off the originating model, but missed updating that page.

It looks like the response to is_anonymised() is getting cached somewhere - we'll take a look. Thanks again!

Hi @HealperRasmus

The docs have been corrected for the next release.

In regard to testing, you'd need to refetch the object in that scenario, if you want some more examples on tests around anonymisation pleasee see https://github.com/wildfish/django-gdpr-assist/blob/develop/tests/test_anonymisation.py

Thanks