from unittest import TestCase from docutils.core import publish_string from docutils.parsers.rst import directives from unitywebgl import config from unitywebgl.UnityGameDirective import UnityWebgl class TestUnityWebgl(TestCase): def test_directive_basic(self): # test directive html output with default template # and settings directives.register_directive('unitywebgl', UnityWebgl) config.GAMES_ROOT_DIR = '/test_games_root' config.TEMPLATE_PATH = '/test_template_path/template' config.DEFAULT_WIDTH = 960 config.DEFAULT_HEIGHT = 600 html =['', '', '
'] res = publish_string('.. unitywebgl:: testgame', writer_name='html', settings_overrides={'output_encoding': 'unicode'}) passed = True for line in html: if line not in res: passed = False break assert passed def test_directive_with_params(self): # test directive html output with all optional parameters, # default template and settings directives.register_directive('unitywebgl', UnityWebgl) config.GAMES_ROOT_DIR = 'test_games_root' config.TEMPLATE_PATH = 'test_template_path' config.DEFAULT_WIDTH = 960 config.DEFAULT_HEIGHT = 600 html =['', '', '
'] d = '.. unitywebgl:: testgame\n\t:gameroot: /games2\n\t:template: /games2/template2\n\t:width: 640\n\t:height: 480' res = publish_string(d, writer_name='html', settings_overrides={'output_encoding': 'unicode'}) passed = True for line in html: if line not in res: passed = False break assert passed