'''
Created on 2020-12-27
@author: wf
'''
import unittest
from frontend.wikicms import Frontend
from tests.test_webserver import TestWebServer
[docs]class TestFrontend(unittest.TestCase):
'''
test the frontend
'''
[docs] def setUp(self):
self.debug=False
self.server=TestWebServer.initServer()
pass
[docs] def tearDown(self):
pass
[docs] def testWikiPage(self):
'''
test the route to page translation
'''
frontend=Frontend('cr')
routes=['/index.php/File:Link.png']
expectedList=['File:Link.png']
for i,route in enumerate(routes):
pageTitle=frontend.wikiPage(route)
if self.debug:
print (pageTitle)
expected=expectedList[i]
self.assertEqual(expected,pageTitle)
pass
[docs] def testProxy(self):
'''
test the proxy handling
'''
frontend=self.server.enableFrontend('sharks')
url="/images/wiki/thumb/6/62/IMG_0736_Shark.png/400px-IMG_0736_Shark.png"
self.assertTrue(frontend.needsProxy(url))
imageResponse=frontend.proxy(url)
self.assertFalse(imageResponse is None)
self.assertEqual("200 OK",imageResponse.status)
self.assertEqual(79499,len(imageResponse.data))
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()