mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-01 22:11:16 +00:00
Mocks celery task for follow request
This commit is contained in:
parent
0c01af4042
commit
48ab993861
1 changed files with 7 additions and 4 deletions
|
@ -2,6 +2,7 @@ import time
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import responses
|
import responses
|
||||||
|
@ -63,16 +64,18 @@ class Signature(TestCase):
|
||||||
send_data=None,
|
send_data=None,
|
||||||
digest=None,
|
digest=None,
|
||||||
date=None):
|
date=None):
|
||||||
|
''' sends a follow request to the "rat" user '''
|
||||||
now = date or http_date()
|
now = date or http_date()
|
||||||
data = json.dumps(get_follow_data(sender, self.rat))
|
data = json.dumps(get_follow_data(sender, self.rat))
|
||||||
digest = digest or make_digest(data)
|
digest = digest or make_digest(data)
|
||||||
signature = make_signature(
|
signature = make_signature(
|
||||||
signer or sender, self.rat.inbox, now, digest)
|
signer or sender, self.rat.inbox, now, digest)
|
||||||
|
with patch('bookwyrm.incoming.handle_follow.delay') as _:
|
||||||
return self.send(signature, now, send_data or data, digest)
|
return self.send(signature, now, send_data or data, digest)
|
||||||
|
|
||||||
# def test_correct_signature(self):
|
def test_correct_signature(self):
|
||||||
# response = self.send_test_request(sender=self.mouse)
|
response = self.send_test_request(sender=self.mouse)
|
||||||
# self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_wrong_signature(self):
|
def test_wrong_signature(self):
|
||||||
''' Messages must be signed by the right actor.
|
''' Messages must be signed by the right actor.
|
||||||
|
|
Loading…
Reference in a new issue