92 lines
3.7 KiB
Python
92 lines
3.7 KiB
Python
from unittest import TestCase
|
|
from flask import Flask
|
|
from rfcartography import create_app
|
|
from rfcartography.index_parser import RFC, NotIssued, STD, BCP, FYI, DocType
|
|
from rfcartography.rfcartographer import RFCartographer
|
|
|
|
|
|
class TestDetailsPages(TestCase):
|
|
def setUp(self):
|
|
"""create an app object for testing purposes"""
|
|
self.app:Flask = create_app()
|
|
self.app.config.update({'TESTING': True})
|
|
|
|
rfc42: RFC = RFC(42)
|
|
rfc23: NotIssued = NotIssued(23)
|
|
std42: STD = STD(42)
|
|
bcp42: BCP = BCP(42)
|
|
fyi42: FYI = FYI(42)
|
|
index: dict[DocType: dict[int, Document]] = {DocType.RFC: {42: rfc42,
|
|
23: rfc23},
|
|
DocType.STD: {42: std42},
|
|
DocType.BCP: {42: bcp42},
|
|
DocType.FYI: {42: fyi42},
|
|
DocType.NIC: {},
|
|
DocType.IEN: {},
|
|
DocType.RTR: {}}
|
|
self.app.cartographer = RFCartographer(index)
|
|
return
|
|
|
|
def test_rfc_details(self):
|
|
"""testing the details page for RFCs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/RFC0042')
|
|
self.assertEqual(response.status, '200 OK')
|
|
return
|
|
|
|
def test_rfc_not_issued_details(self):
|
|
"""testing the details page for not issued RFCs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/RFC0023')
|
|
self.assertEqual(response.status, '200 OK')
|
|
return
|
|
|
|
def test_not_existing_rfc_details(self):
|
|
"""testing the details page requests for not existing RFCs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/RFC0666')
|
|
self.assertEqual(response.status, '404 NOT FOUND')
|
|
return
|
|
|
|
def test_std_details(self):
|
|
"""testing the details page for STDs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/STD0042')
|
|
self.assertEqual(response.status, '200 OK')
|
|
return
|
|
|
|
def test_not_existing_std_details(self):
|
|
"""testing the details page requests for not existing STDs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/STD0666')
|
|
self.assertEqual(response.status, '404 NOT FOUND')
|
|
return
|
|
|
|
def test_bcp_details(self):
|
|
"""testing the details page for BCPs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/BCP0042')
|
|
self.assertEqual(response.status, '200 OK')
|
|
return
|
|
|
|
def test_not_existing_bcp_details(self):
|
|
"""testing the details page requests for not existing BCPs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/BCP0666')
|
|
self.assertEqual(response.status, '404 NOT FOUND')
|
|
return
|
|
|
|
def test_fyi_details(self):
|
|
"""testing the details page for FYIs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/FYI0042')
|
|
self.assertEqual(response.status, '200 OK')
|
|
return
|
|
|
|
def test_not_existing_fyi_details(self):
|
|
"""testing the details page requests for not existing FYIs"""
|
|
client: FlaskClient = self.app.test_client()
|
|
response: TestResponse = client.get('/FYI0666')
|
|
self.assertEqual(response.status, '404 NOT FOUND')
|
|
return
|