Exemplo n.º 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")
Exemplo n.º 2
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")
Exemplo n.º 3
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')
Exemplo n.º 4
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")
Exemplo n.º 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')
Exemplo n.º 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")
Exemplo n.º 7
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 % >")
Exemplo n.º 8
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")
Exemplo n.º 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 % >")
Exemplo n.º 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")