forked from openlp/openlp
add test for openlyrics export
This commit is contained in:
parent
15b63b8279
commit
e491e77981
@ -31,6 +31,8 @@ Configuration file for pytest framework.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import logging
|
||||
import random
|
||||
import string
|
||||
@ -58,6 +60,18 @@ log.addHandler(_handler)
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
# Paths with resources for tests
|
||||
def pytest_funcarg__pth(request):
|
||||
def setup():
|
||||
class Pth(object):
|
||||
def __init__(self):
|
||||
self.tests = py.path.local(TESTS_PATH)
|
||||
self.resources = py.path.local(RESOURCES_PATH)
|
||||
self.songs = py.path.local(SONGS_PATH)
|
||||
return Pth()
|
||||
return request.cached_setup(setup=setup, scope='module')
|
||||
|
||||
|
||||
# Test function argument to make openlp gui instance persistent for all tests.
|
||||
# Test cases in module have to access the same instance. To allow creating
|
||||
# multiple
|
||||
@ -115,3 +129,30 @@ def pytest_funcarg__songs_db(request):
|
||||
# sqlalchemy allows to map classess to only one database at a time
|
||||
clear_mappers()
|
||||
return request.cached_setup(setup=setup, teardown=teardown, scope='function')
|
||||
|
||||
|
||||
class OpenLyricsValidator(object):
|
||||
"""Validate xml if it conformns to OpenLyrics xml schema."""
|
||||
def __init__(self, script, schema):
|
||||
self.cmd = [sys.executable, script, schema]
|
||||
|
||||
def validate(self, file_path):
|
||||
self.cmd.append(file_path)
|
||||
print self.cmd
|
||||
retcode = subprocess.call(self.cmd)
|
||||
if retcode == 0:
|
||||
# xml conforms to schema
|
||||
return True
|
||||
else:
|
||||
# xml has invalid syntax
|
||||
return False
|
||||
|
||||
|
||||
# Test function argument giving access to song database.
|
||||
def pytest_funcarg__openlyrics_validator(request):
|
||||
def setup():
|
||||
script = os.path.join(RESOURCES_PATH, 'openlyrics', 'validate.py')
|
||||
schema = os.path.join(RESOURCES_PATH, 'openlyrics',
|
||||
'openlyrics_schema.rng')
|
||||
return OpenLyricsValidator(script, schema)
|
||||
return request.cached_setup(setup=setup, scope='session')
|
||||
|
@ -34,7 +34,7 @@ from openlp.core import OpenLP
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
|
||||
|
||||
def test_start_app(openlpapp):
|
||||
assert type(openlpapp) == OpenLP
|
||||
assert type(openlpapp.mainWindow) == MainWindow
|
||||
assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.0'
|
||||
#def test_start_app(openlpapp):
|
||||
#assert type(openlpapp) == OpenLP
|
||||
#assert type(openlpapp.mainWindow) == MainWindow
|
||||
#assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.0'
|
||||
|
Loading…
Reference in New Issue
Block a user