def test_save(self): from mortar.exceptions import NotFound from mortar import content self.assertRaises(NotFound, self.storage.load, self.save_id) c = content() c["test"] = "test" self.storage.save(self.save_id) content = self.storage.load(self.save_id) verifyObject(IContent, content) self.assertEqual(content["test"].get(), "test")
def load(self,id): path = os.path.join(self.directory,id)+'.xml' if not os.path.exists(path): raise NotFound('No content with id %r could be found'%id) c = content() t = etree.parse(open(path)) for e in t.xpath('field'): value = e.text for child in e: value += etree.tostring(child) c[e.get('name')]=value return c
def setUp(self): from mortar import content self.content = content()
def test_save(self): from mortar.exceptions import NotSupported from mortar import content c = content() self.assertRaises(NotSupported, self.storage.save, self.load_id)
def setUp(self): self.content = content() self.field = self.content['test']