Ejemplo n.º 1
0
	def test_dump_1(self):
		""" generate node object for 1 story """
		
		m = "This is a story"
		storylist_orig = dpcore.load_stories(m)
		
		nodelist = dpcore.yamlnodedump_stories(storylist_orig[0])
		
		yml = yaml.serialize(nodelist)
		#print yml
		c = yaml.load(yml)
		
		storylist_comp = dpcore.load_stories(c)
		self.assertEqual(storylist_comp[0].story, storylist_orig[0].story)
		self.assertEqual(storylist_comp[0].note, storylist_orig[0].note)
Ejemplo n.º 2
0
	def test_dump_2(self):
		""" generate node object2 for 2 story """
		
		m = ["This is story 1.", {"story": "This is story 2.", "sub-story": "This is a substory.\nwhich have 2 lines.", "task": "task 1.",}]
		storylist_orig = dpcore.load_stories(m)
		
		self.assertEqual(1, len(storylist_orig[1].substory))
		self.assertEqual(1, len(storylist_orig[1].subtask))
		
		nodeobjlist = dpcore.yamlnodedump_stories(storylist_orig)
		nodelist = yaml.SequenceNode(tag=u"tag:yaml.org,2002:seq", value=nodeobjlist, flow_style=False)
		
		yml = yaml.serialize(nodelist)
		#print yml
		c = yaml.load(yml)
		
		storylist_comp = dpcore.load_stories(c)
		for idx in range(2):
			self.assertEqual(storylist_comp[idx].story, storylist_orig[idx].story)
			self.assertEqual(storylist_comp[idx].note, storylist_orig[idx].note)
		self.assertEqual(1, len(storylist_comp[1].substory))
		self.assertEqual(1, len(storylist_comp[1].subtask))