Пример #1
0
 def test_missingTargetWithSpecifier(self):
     """
     A missing target is expanded to a warning about a bad template.
     """
     template = ConceptTemplate(u"{c:pronoun} wins.")
     self.assertEqual(u"<missing target 'c' for 'pronoun' expansion> wins.",
                      self.expandToText(template, dict()))
Пример #2
0
 def test_intermixed(self):
     """
     Literals and subsitution markers may be combined in a single template.
     """
     template = ConceptTemplate(u"{c:pronoun} wins.")
     self.assertEqual(u"she wins.",
                      self.expandToText(template, dict(c=self.thing)))
Пример #3
0
 def test_unexpandedLiteral(self):
     """
     A template string containing no substitution markers expands to itself.
     """
     self.assertEqual(
         u"hello world",
         self.expandToText(ConceptTemplate(u"hello world"), {}))
Пример #4
0
 def test_expandedPronoun(self):
     """
     I{field:pronoun} can be used to substitute the personal pronoun of the
     value given by C{"field"}.
     """
     template = ConceptTemplate(u"{b:pronoun}")
     self.assertEqual(u"she", self.expandToText(template,
                                                dict(b=self.thing)))
Пример #5
0
 def test_expandedName(self):
     """
     I{field:name} can be used to substitute the name of the value given by
     C{"field"}.
     """
     template = ConceptTemplate(u"{a:name}")
     self.assertEqual(u"alice",
                      self.expandToText(template, dict(a=self.thing)))
Пример #6
0
 def test_unsupportedSpecifier(self):
     """
     A specifier not supported on the identified target is expanded to a
     warning about a bad template.
     """
     template = ConceptTemplate(u"{c:glorbex} wins.")
     self.assertEqual(u"<'glorbex' unsupported by target 'c'> wins.",
                      self.expandToText(template, dict(c=self.thing)))
Пример #7
0
 def test_multiples(self):
     """
     Multiple substitution markers may be used in a single template.
     """
     another = Thing(name=u"bob", gender=Gender.FEMALE)
     template = ConceptTemplate(u"{a:name} hits {b:name}.")
     self.assertEqual(
         u"alice hits bob.",
         self.expandToText(template, dict(a=self.thing, b=another)))
Пример #8
0
 def test_adjacent(self):
     """
     Adjacent substitution markers are expanded without introducing
     extraneous intervening characters.
     """
     another = Thing(name=u"bob", gender=Gender.FEMALE)
     template = ConceptTemplate(u"{a:name}{b:name}")
     self.assertEqual(
         u"alicebob",
         self.expandToText(template, dict(a=self.thing, b=another)))