New sombrero test: test_send. The tests are mostly skipped;

the test for "follow" is implemented properly and it currently fails.

Also, some small fiddling on sombrero's test_deliver to remove code rot.
trilby-heavy
Marnanel Thurman 2020-05-05 19:11:43 +01:00
rodzic 6a239db0aa
commit 5e29730370
3 zmienionych plików z 83 dodań i 6 usunięć

Wyświetl plik

@ -11,7 +11,7 @@ to their audiences.
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from kepi.bowler_pub.find import find, find_local, is_local
from kepi.bowler_pub.utils import is_local
import kepi.bowler_pub.models
from httpsig.verify import HeaderVerifier
from urllib.parse import urlparse
@ -26,7 +26,6 @@ import datetime
import pytz
import httpsig
from collections.abc import Iterable
from . import PUBLIC_IDS
logger = logging.getLogger(name='kepi')

Wyświetl plik

@ -9,10 +9,8 @@
from django.test import TestCase, Client
from django.conf import settings
from kepi.bowler_pub.delivery import deliver
from kepi.bowler_pub.create import create
from kepi.bowler_pub.models import AcObject
import kepi.bowler_pub.views as bowler_pub_views
from kepi.sombrero_sendpub.delivery import deliver
import kepi.sombrero_sendpub.views as sombrero_views
from unittest.mock import Mock, patch
from . import *
import logging

Wyświetl plik

@ -0,0 +1,80 @@
# test_send.py
#
# Part of kepi.
# Copyright (c) 2018-2020 Marnanel Thurman.
# Licensed under the GNU Public License v2.
from unittest import skip
from django.test import TestCase
from rest_framework.test import force_authenticate, APIClient
from django.conf import settings
from kepi.sombrero_sendpub.delivery import deliver
from kepi.trilby_api.models import Person
from kepi.trilby_api.tests import create_local_person
import httpretty
REMOTE_URL = 'https://remote.example.net/users/zachary'
class TestSend(TestCase):
def setUp(self):
httpretty.register_uri(
httpretty.POST,
REMOTE_URL,
'', # body is ignored
)
self._zachary = Person(
remote_url = REMOTE_URL,
remote_username = 'zachary',
)
self._zachary.save()
self._alice = create_local_person('alice')
self._client = APIClient()
self._client.force_authenticate(self._alice.local_user)
@skip("TODO - mentions aren't yet implemented")
@httpretty.activate
def test_send_direct_message(self):
result = self._client.post(
path='api/v1/statuses',
format='json',
data = {
'status': '@zachary@remote.example.net Hello world',
'visibility': 'direct',
},
)
self.assertEqual(result.status_code,
200)
@skip("TODO")
def test_irrelevant(self):
pass
@skip("TODO - mentions aren't implemented")
def test_mention(self):
pass
@httpretty.activate
def test_follow(self):
result = self._client.post(
path='api/v1/accounts/%d/follow' % (
self._zachary.id,),
format='json',
)
self.assertEqual(result.status_code,
200)
@skip("TODO")
def test_accept_follow(self):
pass
@skip("TODO")
def test_reject_follow(self):
pass