Package rubacon :: Package backend :: Module test_xml_storage
[hide private]
[frames] | no frames]

Source Code for Module rubacon.backend.test_xml_storage

 1  #!/usr/bin/env python 
 2  # encoding: utf-8 
 3  """ 
 4  test_xml_storage.py 
 5   
 6  Created by Sebastian Höhn on 2008-01-29. 
 7  Copyright (c) 2008 __MyCompanyName__. All rights reserved. 
 8  """ 
 9   
10  import os 
11  from XMLStorage import XMLStorage 
12   
13 -class TestXMLStorage(object):
14
15 - def test_creation(self):
16 """Test creation of XMLStorage""" 17 store = XMLStorage() 18 assert(os.path.exists("data/"))
19
20 - def test_store(self):
21 """Test storing of resources""" 22 store = XMLStorage() 23 store.clearCollection("db.test") 24 store.store("db.test", "<test>me</test>")
25
26 - def test_retrieve(self):
27 """Test retrieval of xml resources""" 28 store = XMLStorage() 29 store.clearCollection("db.test") 30 store.store("db.test", "<a>This is the test entry</a>") 31 res = store.retrieve("db.test", "//a") 32 33 assert res[0].localName == "a"
34
35 - def test_remove(self):
36 """Test removal of resources via XPath""" 37 store = XMLStorage() 38 store.clearCollection("db.test_remove") 39 store.store("db.test_remove", "<a>This is a</a>") 40 store.store("db.test_remove", "<b>This is b</b>") 41 store.removeResource("db.test_remove", "//a")
42 43 44 if __name__ == "__main__": 45 t = TestXMLStorage() 46 t.test_retrieve() 47