Example #1
0
    def __create_tree(self):
        sentinel = StandardNode()
        root = sentinel.add_child("root", NodeState.VISITED)
        i1 = root.add_child("issue1", NodeState.CLOSED)
        i1.add_child("article1-1", NodeState.CLOSED)
        i1.add_child("article1-2", NodeState.CLOSED)

        i2 = root.add_child("issue2", NodeState.VISITED)
        i2.add_child("article2-1", NodeState.OPEN)
        i2.add_child("article2-2", NodeState.CLOSED)
        i2.add_child("article2-3", NodeState.ERROR)

        root.add_child("issue3", NodeState.PROCESSING)

        i4 = root.add_child("issue4", NodeState.ERROR)
        i4.add_child("article4-1", NodeState.PROCESSING)

        t = ("root", NodeState.VISITED,
             [("issue1", NodeState.CLOSED,
               [("article1-1", NodeState.CLOSED, []),
                ("article1-2", NodeState.CLOSED, [])]),
              ("issue2", NodeState.CLOSED,
               [("article2-1", NodeState.OPEN, []),
                ("article2-2", NodeState.CLOSED, []),
                ("article2-3", NodeState.ERROR, [])]),
              ("issue3", NodeState.PROCESSING, []),
              ("issue4", NodeState.ERROR, [("article4-1", NodeState.PROCESSING,
                                            [])])])
        self.assert_(subtrees_equal(t, root))
        return (sentinel, t)
Example #2
0
	def __check_tree_final_state(self, root):
		t = ("root", NodeState.ERROR,
				[("2011-07-12", NodeState.CLOSED, 
					[("01", NodeState.CLOSED, []),
					("02", NodeState.CLOSED, []),
					("03", NodeState.CLOSED, []),
					("04", NodeState.CLOSED, []),
					("05", NodeState.CLOSED, []),
					("06", NodeState.CLOSED, []),
					("07", NodeState.CLOSED, []),
					("08", NodeState.CLOSED, [])]
				),
				("2011-07-13", NodeState.CLOSED, 
					[("01", NodeState.CLOSED, [])]
				),
				("2011-07-14", NodeState.CLOSED, []),
				("2011-07-16", NodeState.ERROR, 
					[("01", NodeState.CLOSED, []),
					("02", NodeState.CLOSED, []),
					("03", NodeState.ERROR, []),
					("04", NodeState.CLOSED, []),
					("05", NodeState.CLOSED, []),
					("06", NodeState.ERROR, []),
					("07", NodeState.CLOSED, [])]
				),
				("2011-07-16-repetition_1", NodeState.CLOSED, 
					[("01", NodeState.CLOSED, []),
					("02", NodeState.CLOSED, []),
					("03", NodeState.CLOSED, [])]
				),
				("2011-07-17", NodeState.ERROR, [])]
			)
		self.assert_(subtrees_equal(t, root))
	def __create_tree(self):
		sentinel = StandardNode()
		root = sentinel.add_child("root", NodeState.VISITED)
		i1 = root.add_child("issue1", NodeState.CLOSED)
		i1.add_child("article1-1", NodeState.CLOSED)
		i1.add_child("article1-2", NodeState.CLOSED)
		
		i2 = root.add_child("issue2", NodeState.VISITED)
		i2.add_child("article2-1", NodeState.OPEN)
		i2.add_child("article2-2", NodeState.CLOSED)
		i2.add_child("article2-3", NodeState.ERROR)
		
		root.add_child("issue3", NodeState.PROCESSING)
		
		i4 = root.add_child("issue4", NodeState.ERROR)
		i4.add_child("article4-1", NodeState.PROCESSING)
		
		t = ("root", NodeState.VISITED,
				[("issue1", NodeState.CLOSED, 
					[("article1-1", NodeState.CLOSED, []),
					("article1-2", NodeState.CLOSED, [])]
				),
				("issue2", NodeState.CLOSED, 
					[("article2-1", NodeState.OPEN, []),
					("article2-2", NodeState.CLOSED, []),
					("article2-3", NodeState.ERROR, [])]
				),
				("issue3", NodeState.PROCESSING, []),
				("issue4", NodeState.ERROR, 
					[("article4-1", NodeState.PROCESSING, [])]
				)]
			)
		self.assert_(subtrees_equal(t, root))
		return (sentinel, t)
	def test_basic_write_and_read(self):
		(sentinel, schema_root) = self.__create_tree()
		out = StringIO.StringIO()
		writer = XMLTreeWriter(out)
		writer.write(sentinel)
		out_str = out.getvalue()
		in_ = StringIO.StringIO(out_str)
		reader = XMLTreeReader(in_)
		new_sentinel = StandardNode()
		reader.read(new_sentinel)
		self.assert_(subtrees_equal(schema_root, new_sentinel.get_child("root")))
		out2 = StringIO.StringIO()
		writer2 = XMLTreeWriter(out2)
		writer2.write(new_sentinel)
		out2_str = out2.getvalue()
		self.assertEqual(out_str, out2_str)
Example #5
0
 def test_basic_write_and_read(self):
     (sentinel, schema_root) = self.__create_tree()
     out = StringIO.StringIO()
     writer = XMLTreeWriter(out)
     writer.write(sentinel)
     out_str = out.getvalue()
     in_ = StringIO.StringIO(out_str)
     reader = XMLTreeReader(in_)
     new_sentinel = StandardNode()
     reader.read(new_sentinel)
     self.assert_(
         subtrees_equal(schema_root, new_sentinel.get_child("root")))
     out2 = StringIO.StringIO()
     writer2 = XMLTreeWriter(out2)
     writer2.write(new_sentinel)
     out2_str = out2.getvalue()
     self.assertEqual(out_str, out2_str)
Example #6
0
 def __check_tree_final_state(self, root):
     t = ("root", NodeState.ERROR,
          [("2011-07-12", NodeState.CLOSED, [("01", NodeState.CLOSED, []),
                                             ("02", NodeState.CLOSED, []),
                                             ("03", NodeState.CLOSED, []),
                                             ("04", NodeState.CLOSED, []),
                                             ("05", NodeState.CLOSED, []),
                                             ("06", NodeState.CLOSED, []),
                                             ("07", NodeState.CLOSED, []),
                                             ("08", NodeState.CLOSED, [])]),
           ("2011-07-13", NodeState.CLOSED, [("01", NodeState.CLOSED, [])]),
           ("2011-07-14", NodeState.CLOSED, []),
           ("2011-07-16", NodeState.ERROR, [("01", NodeState.CLOSED, []),
                                            ("02", NodeState.CLOSED, []),
                                            ("03", NodeState.ERROR, []),
                                            ("04", NodeState.CLOSED, []),
                                            ("05", NodeState.CLOSED, []),
                                            ("06", NodeState.ERROR, []),
                                            ("07", NodeState.CLOSED, [])]),
           ("2011-07-16-repetition_1", NodeState.CLOSED,
            [("01", NodeState.CLOSED, []), ("02", NodeState.CLOSED, []),
             ("03", NodeState.CLOSED, [])]),
           ("2011-07-17", NodeState.ERROR, [])])
     self.assert_(subtrees_equal(t, root))