def test_chirp_testcase_is_included(): assert not chirp.is_instrumented() chirp.instrument_site(True) request = get_request_fixture() c = RequestContext(request, {}) pa = PageAssembly('dummyapp/page/chirp.yaml', c) content = pa.dumps() assert 'dojo.require(\'ChirpTools.TestRunner' in content assert 'dojo.require(\'ChirpTools.Mvc' in content assert 'ChirpTools.TestRunner.TestCaseCollector' in content
def test_instrument(): assert not chirp.is_instrumented() chirp.instrument_site(True) py.test.raises(chirp.ChirpError, chirp.instrument_site, True) assert chirp.is_instrumented() chirp.instrument_site(False) assert not chirp.is_instrumented() settings.SKYLARK_CHIRP_INSTRUMENTED = True # This only get's triggered if we render a page, so let's do that request = get_request_fixture() c = RequestContext(request, {}) sa = SnippetAssembly('dummyapp/snippet/snippet.yaml', c) content = sa.dumps() assert chirp.is_instrumented() settings.SKYLARK_CHIRP_INSTRUMENTED = False
def interface_start(request): """ Provides the main HTML for the test runner """ if not is_instrumented(): instrument_site(True) teps = [ i.__dict__ for i in test_registry.list() ] context = RequestContext(request, { 'test_count': len(test_registry), 'test_entry_points_json': simplejson.dumps(teps), 'url_deinstrument': reverse(deinstrument), }) pa = PageAssembly('chirp/testrunner/display/display.yaml', context) return pa.get_http_response()
def test_chirp_includes_tests(): assert not chirp.is_instrumented() chirp.instrument_site(True) request = get_request_fixture() c = RequestContext(request, {}) pa = PageAssembly('dummyapp/page/chirp.yaml', c) content = pa.dumps() assert "dojo.require('DynamicApp.Page.Test')" in content chirp.instrument_site(False) c = RequestContext(request, {}) pa = PageAssembly('dummyapp/page/chirp.yaml', c) content = pa.dumps() assert "dojo.require('DynamicApp.Page.Test')" not in content
def test_deploy_fewest_instrumented(): hash_js = "cb0aa470231a819d45ee02783f5fc468" chirp.instrument_site(True) settings.SKYLARK_PLANS = "mediadeploy_fewest" request = get_request_fixture() c = RequestContext(request) pa = PageAssembly("planapp/page/full.yaml", c) content = pa.dumps() assert "%s.js" % hash_js in content jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js)) assert "dojo.provide('chirp')" in jsfile chirp.instrument_site(False)
def teardown_chirp(): teardown() chirp.instrument_site(False) chirp.test_registry.clear()
def test_chirp_autodiscover(): chirp.autodiscover() assert 'dummyapp.chirp' in chirp._chirp_modules chirp.instrument_site(True) assert 'dummyapp.chirp' in sys.modules
def deinstrument(request): """ Called at the end of the test run, de-instuments the site for testing """ instrument_site(False) return HttpResponse()