Some WIP progress on writing webpush tests
This commit is contained in:
parent
6542993bf0
commit
fbb58b1737
@ -17,6 +17,7 @@ test_runner = DiscoverRunner(verbosity=1)
|
|||||||
|
|
||||||
failures = test_runner.run_tests([
|
failures = test_runner.run_tests([
|
||||||
'djangoldp_webpushnotification.tests.tests_vapidkeyset',
|
'djangoldp_webpushnotification.tests.tests_vapidkeyset',
|
||||||
|
'djangoldp_webpushnotification.tests.tests_accept_subscription',
|
||||||
])
|
])
|
||||||
if failures:
|
if failures:
|
||||||
sys.exit(failures)
|
sys.exit(failures)
|
||||||
|
@ -4,9 +4,7 @@ yaml_config = """
|
|||||||
dependencies:
|
dependencies:
|
||||||
|
|
||||||
ldppackages:
|
ldppackages:
|
||||||
|
- djangoldp_account
|
||||||
- djangoldp_webpushnotification
|
- djangoldp_webpushnotification
|
||||||
- djangoldp_webpushnotification.tests
|
- djangoldp_webpushnotification.tests
|
||||||
|
|
||||||
server:
|
|
||||||
INSTALLED_APPS: []
|
|
||||||
"""
|
"""
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.test import TestCase
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestAcceptSubscription(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.factory = APIRequestFactory()
|
||||||
|
self.client = APIClient()
|
||||||
|
self.user = get_user_model().objects.create_user(username='john', email='jlennon@beatles.com', password='glass onion')
|
||||||
|
self.client.force_authenticate(self.user)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.user.delete()
|
||||||
|
|
||||||
|
def test_accept_sub(self):
|
||||||
|
payload = {
|
||||||
|
"status_type": "subscribe",
|
||||||
|
"subscription": {
|
||||||
|
"endpoint": "example.com",
|
||||||
|
"keys": {
|
||||||
|
"auth": "barfoo",
|
||||||
|
"p256dh": "foobar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"browser": "firefox"
|
||||||
|
}
|
||||||
|
|
||||||
|
url = reverse("save_webpush_info")
|
||||||
|
response = self.client.post(url, data=json.dumps(payload), content_type='application/json')
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 201)
|
Reference in New Issue
Block a user