예제 #1
0
		def test_ink_renderer_default_delimiters(self):
			"""Test new Ink renderer assignment of default delimiters from the template"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			renderer = Renderer(template, self.key_dictionary)
			self.assertEqual(renderer.odel, "{{")
			self.assertEqual(renderer.cdel, "}}")
예제 #2
0
		def test_ink_renderer_new_delimiters(self):
			"""Test new Ink renderer assignment of new delimiters from the template"""
			template_string = FileReader(self.template_path2).read_utf8()
			template = Template(template_string, "[[", "]]")
			renderer = Renderer(template, self.key_dictionary)
			self.assertEqual(renderer.odel, "[[")
			self.assertEqual(renderer.cdel, "]]")
예제 #3
0
		def test_ink_renderer_render_fail_with_incorrect_delim(self):
			"""Confirm that Ink renderer fails with incorrect delimiter assignment"""
			template_string = FileReader(self.template_path).read_utf8()
			standard_string = FileReader(self.standard_path).read_utf8()
			template = Template(template_string, "[[", "]]")
			renderer = Renderer(template, self.key_dictionary)
			rendered_doc = renderer.render()
			self.assertNotEqual(rendered_doc, standard_string)
예제 #4
0
		def test_ink_renderer_render_new_delim(self):
			"""Test Ink render with new delimiters"""
			template_string = FileReader(self.template_path2).read_utf8()
			standard_string = FileReader(self.standard_path).read_utf8()
			template = Template(template_string, "[[", "]]", escape_regex=True) # have to escape special regex chars
			renderer = Renderer(template, self.key_dictionary)
			rendered_doc = renderer.render()
			self.assertEqual(rendered_doc, standard_string)
예제 #5
0
		def test_ink_renderer_render_default_delim(self):
			"""Test Ink render with default delimiters"""
			template_string = FileReader(self.template_path).read_utf8()
			standard_string = FileReader(self.standard_path).read_utf8()
			template = Template(template_string)
			renderer = Renderer(template, self.key_dictionary)
			rendered_doc = renderer.render()
			self.assertEqual(rendered_doc, standard_string)
예제 #6
0
		def test_ink_make_template_varlist_new_delimiters(self):
			"""Test new Ink template variable list property assignment with new delimiters"""
			template_string = FileReader(self.template_path2).read_utf8()
			template = Template(template_string, "[[", "]]", escape_regex=True) # have to escape special regex chars
			if state.py2:
				# pass - need to skip this for Py3.2 tests
				self.assertEqual(template.varlist, set([u'appname', u'description', u'url', u'license', u'author', u'email']))
			else:
				self.assertEqual(template.varlist, set(['appname', 'description', 'url', 'license', 'author', 'email']))
예제 #7
0
		def test_ink_make_template_varlist(self):
			"""Test new Ink template variable list property assignment"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			if state.py2:
				# pass - need to skip this for Py3.2 tests
			    self.assertEqual(template.varlist, set([u'appname', u'description', u'url', u'license', u'author', u'email'])) # convert to sets to ignore order
			else:
				self.assertEqual(template.varlist, set(['appname', 'description', 'url', 'license', 'author', 'email']))
예제 #8
0
		def test_ink_make_template_varlist_new_delimiter_wrong_delim(self):
			"""Test new Ink template variable list property assignment when new delimiter is wrong"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string, "[[", "]]", escape_regex=True) # have to escape special regex chars
			self.assertEqual(template.varlist, set([]))
예제 #9
0
		def test_ink_make_template_varlist_default_delim_wrong_delim(self):
			"""Test new Ink template variable list property assignment when default delimiter is incorrect"""
			template_string = FileReader(self.template_path2).read_utf8() # uses the [[ & ]] delimiters
			template = Template(template_string)
			self.assertEqual(template.varlist, set([]))
예제 #10
0
		def test_ink_make_template_string(self):
			"""Test new Ink template string assignment"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			self.assertEqual(template, template_string)
예제 #11
0
		def test_ink_make_template_new_delimiters_without_escape(self):
			"""test new Ink template delimiter properties assignment fails without proper regex escape"""
			template_string = FileReader(self.template_path).read_utf8()
			self.assertRaises(TypeError, Template(template_string, "[[", "]]"))
예제 #12
0
		def test_ink_make_template_default_delimiter(self):
			"""Test default Ink template delimiter properties assignment"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			self.assertEqual(template.odel, "{{")
			self.assertEqual(template.cdel, "}}")
예제 #13
0
		def test_ink_renderer_key_dictionary(self):
			"""Test new Ink renderer key_dict property"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			renderer = Renderer(template, self.key_dictionary)
			self.assertEqual(renderer.key_dict, self.key_dictionary)
예제 #14
0
		def test_ink_renderer_template_property_string(self):
			"""Test new Ink renderer template property is a string"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			renderer = Renderer(template, self.key_dictionary)
			self.assertIsInstance(renderer.template, str)
예제 #15
0
		def test_ink_template_type_string(self):
			"""Test that Ink template is of type string"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			self.assertIsInstance(template, str)
예제 #16
0
		def test_ink_make_template_new_delimiters(self):
			"""Test new Ink template delimiter properties assignment"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string, "[[", "]]", escape_regex=True)
			self.assertEqual(template.odel, "[[")
			self.assertEqual(template.cdel, "]]")
예제 #17
0
		def test_ink_template_varlist_type_set(self):
			"""Test that the Ink template variable list is of type set"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			self.assertIsInstance(template.varlist, set)
예제 #18
0
		def test_ink_template_string_method(self):
			"""Test that a slice string method works on the Ink template"""
			template_string = FileReader(self.template_path).read_utf8()
			template = Template(template_string)
			self.assertEqual(template[0:5], "impor")