def test_save_to_data(self): metadata = Metadata() metadata.set_property('version', 'v0.1') metadata.set_property('summary', {'title': 'test_title'}) data = metadata.save_to_data() metadata = Metadata() metadata.load_from_data(data) self.assertEqual(metadata['version'], 'v0.1') self.assertEqual(metadata['summary']['title'], 'test_title')
def test_load_from_data_invalid(self): metadata = Metadata() with self.assertRaises(yaml.YAMLError): metadata.load_from_data("{{{}} invalid")
def test_load_from_data(self): metadata = Metadata() metadata.load_from_data("version: v0.1") self.assertEqual(metadata['version'], 'v0.1')