Package oort :: Package test :: Module test_sitebase
[hide private]
[frames] | no frames]

Source Code for Module oort.test.test_sitebase

 1  #======================================================================= 
 2  from rdflib import ConjunctiveGraph 
 3  from oort.sitebase import MultiBaseResourceViewer, AspectBase 
 4  #======================================================================= 
 5   
 6   
7 -class TestResourceViewerBase:
8 pass # TODO: test at least __call__- and app_factory!
9 10
11 -def test_MultiBaseResourceViewer():
12 # TODO: verify test accuracy; then remake into test generator (see nose) 13 14 class TestViewer(MultiBaseResourceViewer): 15 resourceBases = { 16 'ont': ("http://example.org/rdfns/ontology#", ''), 17 'ex': ("http://example.org/resources/", "/"), 18 'urn': ("urn:example-org:", ":"), 19 } 20 defaultResource = 'http://example.org/default/resource'
21 22 viewer = TestViewer(ConjunctiveGraph()) 23 def test_path(path, expected, samePath=True): 24 resource = viewer.resource_from(path.split('/')) 25 assert resource == expected 26 path2, _success = viewer.resource_to_app_path(resource) 27 assert (path == path2) is samePath 28 29 test_path("ex/path/to/resource", "http://example.org/resources/path/to/resource") 30 test_path("ex/", "http://example.org/resources/") 31 test_path("ont/OneConcept", "http://example.org/rdfns/ontology#OneConcept") 32 test_path("ont/someRelationTo", "http://example.org/rdfns/ontology#someRelationTo") 33 test_path("bad/nothing/to/see/here", "http://example.org/default/resource", False) 34 test_path("bad/", "http://example.org/default/resource", False) 35 test_path("/", "http://example.org/default/resource", False) 36 test_path("", "http://example.org/default/resource", False) 37 38
39 -def test_using():
40 dummy = object() 41 aspect = AspectBase(None) 42 assert aspect == aspect.using(item=dummy) 43 assert aspect.queries['item'] == dummy
44