Activity.deserialize() correctly accesses its list of types.

First test for it (which found the above bug).
thingy_objects
Marnanel Thurman 2018-09-12 02:50:08 +01:00
rodzic 8c3d13ed46
commit 140dfe795f
2 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -510,7 +510,7 @@ class Activity(models.Model):
}
try:
need_actor, need_object, need_target = TYPES[value['type']]
need_actor, need_object, need_target = cls.TYPES[value['type']]
except KeyError:
raise ValueError('{} is not an Activity type'.format(value['type']))

Wyświetl plik

@ -0,0 +1,12 @@
from django.test import TestCase
from django_kepi.models import Activity
class TestActivity(TestCase):
def test_parameters(self):
with self.assertRaisesMessage(ValueError, "is not an Activity type"):
Activity.deserialize({
"id": "https://example.com/id/1",
"type": "Wombat",
})