2018-09-12 01:50:08 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django_kepi.models import Activity
|
2018-09-12 22:49:25 +00:00
|
|
|
from things_for_testing.models import ThingArticle, ThingUser
|
2018-09-12 01:50:08 +00:00
|
|
|
|
|
|
|
class TestActivity(TestCase):
|
|
|
|
|
|
|
|
def test_parameters(self):
|
|
|
|
|
|
|
|
with self.assertRaisesMessage(ValueError, "is not an Activity type"):
|
2018-09-16 20:42:27 +00:00
|
|
|
Activity.create({
|
2018-09-12 22:49:25 +00:00
|
|
|
"id": "https://example.com/id/1",
|
|
|
|
"type": "Wombat",
|
|
|
|
})
|
|
|
|
|
|
|
|
with self.assertRaisesMessage(ValueError, "Remote activities must have an id"):
|
2018-09-16 20:42:27 +00:00
|
|
|
Activity.create({
|
2018-09-12 22:49:25 +00:00
|
|
|
"type": "Create",
|
2019-03-03 21:30:18 +00:00
|
|
|
"actor": "https://example.com/user/fred",
|
|
|
|
"object": {
|
|
|
|
"type": "Article",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sender="https://remote.example.com")
|
2018-09-12 22:49:25 +00:00
|
|
|
|
|
|
|
with self.assertRaisesMessage(ValueError, "Wrong parameters for type"):
|
2018-09-16 20:42:27 +00:00
|
|
|
Activity.create({
|
2018-09-12 22:49:25 +00:00
|
|
|
"id": "https://example.com/id/1",
|
|
|
|
"type": "Create",
|
|
|
|
})
|
|
|
|
|
2018-09-16 20:49:08 +00:00
|
|
|
fred = ThingUser(name="fred")
|
|
|
|
fred.save()
|