e9fce6b2e41c1129f4305eda0adcfc262bcc21c5
[nepi.git] / test / util / parser.py
1 #!/usr/bin/env python
2 #
3 #    NEPI, a framework to manage network experiments
4 #    Copyright (C) 2013 INRIA
5 #
6 #    This program is free software: you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation, either version 3 of the License, or
9 #    (at your option) any later version.
10 #
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20
21
22 from nepi.design.box import Box 
23 from nepi.util.parser import XMLParser
24
25 import unittest
26
27 class BoxDesignTestCase(unittest.TestCase):
28     def test_to_xml(self):
29         node1 = Box()
30         node2 = Box()
31
32         node1.label = "node1"
33         node2.label = "node2"
34
35         node1.connect(node2)
36
37         node1.a.dog = "cat"
38         node1.a.one = "two"
39         node1.a.t = "q"
40
41         node1.c.node2.a.sky = "sea"
42         node2.a.bee = "honey"
43
44         node1.tadd("unooo")
45         node2.tadd("dosss")
46
47         parser = XMLParser()
48         xml = parser.to_xml(node1)
49         
50         node = parser.from_xml(xml)
51         xml2 = parser.to_xml(node)
52         
53         self.assertEquals(xml, xml2)
54
55 if __name__ == '__main__':
56     unittest.main()
57