def ccengine_app_factory(global_config, **kw): if kw.has_key('direct_remote_path'): staticdirector = staticdirect.RemoteStaticDirect( kw['direct_remote_path'].strip()) elif kw.has_key('direct_remote_paths'): staticdirector = staticdirect.MultiRemoteStaticDirect( dict([line.strip().split(' ', 1) for line in kw['direct_remote_paths'].strip().splitlines()])) else: raise ImproperlyConfigured( "One of direct_remote_path or direct_remote_paths must be provided") return CCEngineApp(staticdirector, config=kw)
### --------------- ### routing testing ### --------------- def test_routing(): pass ### ------------ ### view testing ### ------------ TESTAPP = webtest.TestApp( app.CCEngineApp(staticdirect.RemoteStaticDirect('/static/'), {})) # XXX: Move to test_app? def test_404(): response = TESTAPP.get('/haha-i-dont-exist/', status=404) # You'd better be sorry! assert u'Sorry...' in response.unicode_body def test_root_view(): response = TESTAPP.get('/') assert_equal(response.body, 'This is the root')
dropdown - All the license deeds mentioned on the individual jurisdiction pages are GET'able with a 200 response code """ import re from lxml import html import webtest from cc.engine import app, staticdirect TESTAPP = webtest.TestApp( app.CCEngineApp( staticdirect.RemoteStaticDirect('/static/'), {})) def scraped_launched_jurisdictions(): international_dom = html.parse('http://creativecommons.org/international/') completed_block = international_dom.xpath( "id('blocks')/div/div[@class='icontainer']")[0] jurisdictions = [ a.attrib['href'].strip('/').split('/')[1] for a in completed_block.xpath("div/a")] return jurisdictions def scraped_expected_licenses(jurisdiction): juris_deed_re = re.compile(
def test_remote_staticdirect(): sd = staticdirect.RemoteStaticDirect('/statik') assert sd('/foo/') == '/statik/foo/' assert sd('/foo/bar/baz') == '/statik/foo/bar/baz' assert sd('blah') == '/statik/blah'
def test_request_dot_staticdirect(): testapp = webtest.TestApp( app.CCEngineApp(staticdirect.RemoteStaticDirect('/statik/'), {})) response = testapp.get('/licenses/by/3.0/') assert u'/statik/images/information.png' in response.unicode_body assert u'/statik/includes/deed3.css' in response.unicode_body