25 changes: 12 additions & 13 deletions tests/frontend/mainpage_tests.py
Expand Up @@ -27,26 +27,25 @@ def test_pages(self):
self.assertIn('<h1>Credits</h1>', self.assertOk(r).data)

def test_moduleloaded(self):
from silpa.loadconfig import config
modules = [module for module, need in config.items('modules')
if need == "yes"]
module_display = sorted((display_name
for module, display_name in
config.items('module_display')
if module in modules))
from silpa.helper import ModuleConfigHelper
module_display = ModuleConfigHelper.get_module_displaynames()

r = self.get('/')
self.assertOk(r)

for m in module_display:
for m, d in module_display.items():
# FIXME: Returned by configparser is unicode string for
# some reason breaks with assertIn not sure why :(
self.assertIn(m.encode('utf-8'), r.data)
self.assertIn(d.encode('utf-8'), r.data)

# TODO: URL in modules needs to be fixed befor enabling
# below tests
# r1 = self.get('/' + m)
# self.assertIn('<title> {} - Indic Language Computing Platform ' +
# '</title>', self.assertOk(r1).data)
# below tests, for now skip transliteration which is
# enabled in test conf but url is not fixed
if m != 'transliteration':
r1 = self.get('/' + m)
self.assertIn('<title> ' + m.encode('utf-8') +
' - Indic Language Computing Platform' +
' </title>', self.assertOk(r1).data)

def test_pagenotfound(self):
r = self.get('/blablabla')
Expand Down
60 changes: 60 additions & 0 deletions tests/resources/silpa.conf
@@ -0,0 +1,60 @@
[main]
# SITE Name
site = SILPA

# If your site is not hosted in document root please give baseurl
# eg: www.example.org/silpa
# Leave the / if SILPA is hosted directly under documentroot
# leave it as / if you are using WSGI even if you are not under document root
baseurl = /

[logging]
# Set a logging level
# Allowed values are info,debug,warn,error
log_level = debug

# Which folder log should be located
log_folder = /tmp

# log file name
log_name = silpa.log

[modules]
# These section provides list of modules use
# 'yes' to enable them and 'no' to disable
spellchecker = no
inexactsearch = yes
soundex = yes
transliteration = yes
hyphenation = no
chardetails = no
payyans = no
indicsyllabifier = no
indicfortune = no
ucasort = no
indicngram = no
shingling = no
textsimilarity = no
indicstemmer = no
katapayadi = no
scriptrender = no

[module_display]
# Section gives names to be displayed on HTML and
# additionally the end point for each module
soundex = Soundex
inexactsearch = ApproxSearch
spellchecker = SpellCheck
transliteration = Transliteration
hyphenation = Hyphenate
chardetails = Chardetails
payyans = Payyans
indicsyllabifier = Syllabalizer
indicfortune = Fortune
ucasort = UCA Sort
indicngram = N-gram
shingling = Shingling
textsimilarity = Similar Texts
indicstemmer = Stemmer
katapayadi = Katapayadi Numbers
scriptrender = Script Render
11 changes: 9 additions & 2 deletions wsgi.py
Expand Up @@ -2,6 +2,13 @@
from werkzeug.wsgi import DispatcherMiddleware

from silpa import api, frontend
import os

application = DispatcherMiddleware(frontend.create_app(),
{'/api': api.create_app()})
conffile = os.path.join(os.path.dirname(__file__), "etc", "silpa.conf")

application = DispatcherMiddleware(frontend.create_app(conffile),
{'/api': api.create_app(conffile)})

if __name__ == "__main__":
run_simple('0.0.0.0', 5000, application,
use_reloader=True, use_debugger=True)