Example #1
0
    def test_substitution_with_spaces(self):
        template = NetworkTemplate("a: <% a%>, b: <%b %>, "
                                   "c: <% c %>, d: <%   d%>")
        substituted_string = template.safe_substitute(a='aaa', b='bbb',
                                                      c='ccc', d='ddd')

        self.assertEqual(substituted_string, "a: aaa, b: bbb, c: ccc, d: ddd")
    def test_substitution_with_spaces(self):
        template = NetworkTemplate("a: <% a%>, b: <%b %>, "
                                   "c: <% c %>, d: <%   d%>")
        substituted_string = template.safe_substitute(a='aaa', b='bbb',
                                                      c='ccc', d='ddd')

        self.assertEqual(substituted_string, "a: aaa, b: bbb, c: ccc, d: ddd")
    def test_substitution_with_missed_key(self):
        template = NetworkTemplate("a: <%a%>")
        substituted_string = template.safe_substitute(b='bbb')

        self.assertEqual(substituted_string, "a: <%a%>")
        self.assertRaises(KeyError,
                          template.substitute,
                          b='bbb')
    def test_substitution_with_extra_keys(self):
        template = NetworkTemplate("a: <%a%>")

        substituted_string = template.safe_substitute(a='aaa', b='bbb')
        self.assertEqual(substituted_string, "a: aaa")

        substituted_string = template.substitute(a='aaa', b='bbb')
        self.assertEqual(substituted_string, "a: aaa")
Example #5
0
    def test_substitution_with_missed_key(self):
        template = NetworkTemplate("a: <%a%>")
        substituted_string = template.safe_substitute(b='bbb')

        self.assertEqual(substituted_string, "a: <%a%>")
        self.assertRaises(KeyError,
                          template.substitute,
                          b='bbb')
Example #6
0
    def test_substitution_with_extra_keys(self):
        template = NetworkTemplate("a: <%a%>")

        substituted_string = template.safe_substitute(a='aaa', b='bbb')
        self.assertEqual(substituted_string, "a: aaa")

        substituted_string = template.substitute(a='aaa', b='bbb')
        self.assertEqual(substituted_string, "a: aaa")
    def test_substitution_with_no_match(self):
        template = NetworkTemplate("a: <%a b: <% b % >")
        substituted_string = template.safe_substitute(a='aaa', b='bbb')

        self.assertEqual(substituted_string, "a: <%a b: <% b % >")
    def test_simple_substitution(self):
        template = NetworkTemplate("a: <%a%>, b: <%b%>")
        substituted_string = template.safe_substitute(a='aaa', b='bbb')

        self.assertEqual(substituted_string, "a: aaa, b: bbb")
Example #9
0
    def test_substitution_with_no_match(self):
        template = NetworkTemplate("a: <%a b: <% b % >")
        substituted_string = template.safe_substitute(a='aaa', b='bbb')

        self.assertEqual(substituted_string, "a: <%a b: <% b % >")
Example #10
0
    def test_simple_substitution(self):
        template = NetworkTemplate("a: <%a%>, b: <%b%>")
        substituted_string = template.safe_substitute(a='aaa', b='bbb')

        self.assertEqual(substituted_string, "a: aaa, b: bbb")