Esempio n. 1
0
    def test_valid_index_value(self):
        node = TemplateIndexedNode()

        node.set_attrib("index", TemplateWordNode("1"))

        node.set_attrib("index", TemplateWordNode("1, 2"))

        node.set_attrib("index", "1")

        node.set_attrib("index", "1, 2")

        node.set_attrib("index", "1, *")
Esempio n. 2
0
 def test_invalid_attrib_name(self):
     with self.assertRaises(Exception):
         node = TemplateIndexedNode()
         node.set_attrib('rubbish', 3)
Esempio n. 3
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', 3)
     self.assertEqual(3, node.index)
Esempio n. 4
0
    def test_attrib_name_position_and_index_invalid(self):
        node = TemplateIndexedNode()

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1 3")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "0,1")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1,0")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "0,0")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1,x")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "x,1")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "x,x")
Esempio n. 5
0
 def test_attrib_name_position_and_index_as_star(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', "1,*")
     self.assertEqual(1, node.position)
     self.assertEqual(1, node.index)
Esempio n. 6
0
    def test_invalid_index_value(self):
        node = TemplateIndexedNode()

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x, 1"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("1, x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x, x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("*, 1"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("1, 2, 3"))
Esempio n. 7
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', TemplateWordNode("3"))
     self.assertEqual("3", node.index.word)
Esempio n. 8
0
 def test_invalid_attrib_name(self):
     with self.assertRaises(Exception):
         node = TemplateIndexedNode()
         node.set_attrib('rubbish', 3)
Esempio n. 9
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', 3)
     self.assertEqual(3, node.index)