noop test_protocol for_domain/for_request refactoring

pull/545/head
Ryan Barrett 2023-06-12 14:17:44 -07:00
rodzic 239976ca43
commit e7f8710cc4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 18 dodań i 18 usunięć

Wyświetl plik

@ -43,24 +43,24 @@ class ProtocolTest(TestCase):
self.assertEqual(Web, PROTOCOLS['web']) self.assertEqual(Web, PROTOCOLS['web'])
self.assertEqual(Web, PROTOCOLS['webmention']) self.assertEqual(Web, PROTOCOLS['webmention'])
def test_for_domain(self): def test_for_domain_for_request(self):
self.assertEqual(Fake, Protocol.for_domain('fake.brid.gy')) for domain, protocol in [
self.assertEqual(ActivityPub, Protocol.for_domain('ap.brid.gy')) ('fake.brid.gy', Fake),
self.assertEqual(ActivityPub, Protocol.for_domain('activitypub.brid.gy')) ('ap.brid.gy', ActivityPub),
('activitypub.brid.gy', ActivityPub),
for bad in [None, '', 'fake', 'fake.com', 'brid.gy', 'www.brid.gy', ('web.brid.gy', Web),
'fed.brid.gy', 'fake.fed.brid.gy']: ('fed.brid.gy', Web),
self.assertIsNone(Protocol.for_domain(bad)) (None, None),
('', None),
def test_for_request(self): ('brid.gy', None),
with app.test_request_context('/', base_url='https://fake.brid.gy/'): ('www.brid.gy', None),
self.assertEqual(Fake, Protocol.for_request()) ('fake.fed.brid.gy', None),
('fake', None),
with app.test_request_context('/foo', base_url='http://ap.brid.gy/'): ('fake.com', None),
self.assertEqual(ActivityPub, Protocol.for_request()) ]:
self.assertEqual(protocol, Protocol.for_domain(domain))
for bad in None, '', 'brid.gy', 'fake.fed.brid.gy': with app.test_request_context('/foo', base_url=f'https://{domain}/'):
self.assertIsNone(Protocol.for_request()) self.assertEqual(protocol, Protocol.for_request())
@patch('requests.get') @patch('requests.get')
def test_receive_reply_not_feed_not_notification(self, mock_get): def test_receive_reply_not_feed_not_notification(self, mock_get):