def test_garbage_json(self): responses.add( responses.GET, 'http://example.com', body='xxxx', content_type='application/json' ) with pytest.raises(UnparseableSourcemap): fetch_sourcemap('http://example.com')
def test_simple_non_utf8(self): responses.add(responses.GET, 'http://example.com', body='{}', content_type='application/json; charset=NOPE') with pytest.raises(CannotFetchSource) as exc: fetch_sourcemap('http://example.com') assert exc.value.data['type'] == EventError.JS_INVALID_SOURCE_ENCODING
def test_base64_without_padding(self): smap_view = fetch_sourcemap(base64_sourcemap.rstrip('=')) tokens = [Token(1, 0, '/test.js', 0, 0, 0, None)] assert list(smap_view) == tokens assert smap_view.get_source_contents(0) == 'console.log("hello, World!")' assert smap_view.get_source_name(0) == u'/test.js'
def test_simple_base64(self): smap_view = fetch_sourcemap(base64_sourcemap) tokens = [Token(1, 0, '/test.js', 0, 0, 0, None)] assert list(smap_view) == tokens assert smap_view.get_source_contents(0) == 'console.log("hello, World!")' assert smap_view.get_source_name(0) == u'/test.js'
def test_simple(self): index = fetch_sourcemap(base64_sourcemap) states = [SourceMap(1, 0, '/test.js', 0, 0, None)] sources = set(['/test.js']) keys = [(1, 0)] content = {'/test.js': ['console.log("hello, World!")']} assert index == SourceMapIndex(states, keys, sources, content)
def test_base64_without_padding(self): smap_view = fetch_sourcemap(base64_sourcemap.rstrip('=')) tokens = [SourceMapTokenMatch(0, 0, 1, 0, src='/test.js', src_id=0)] assert list(smap_view) == tokens sv = smap_view.get_sourceview(0) assert sv.get_source() == u'console.log("hello, World!")' assert smap_view.get_source_name(0) == u'/test.js'
def test_simple_base64(self): smap_view = fetch_sourcemap(base64_sourcemap) tokens = [SourceMapTokenMatch(0, 0, 1, 0, src='/test.js', src_id=0)] assert list(smap_view) == tokens sv = smap_view.get_sourceview(0) assert sv.get_source() == u'console.log("hello, World!")' assert smap_view.get_source_name(0) == u'/test.js'
def test_base64_without_padding(self): smap_view = fetch_sourcemap(base64_sourcemap.rstrip("=")) tokens = [SourceMapTokenMatch(0, 0, 1, 0, src="/test.js", src_id=0)] assert list(smap_view) == tokens sv = smap_view.get_sourceview(0) assert sv.get_source() == 'console.log("hello, World!")' assert smap_view.get_source_name(0) == "/test.js"
def test_broken_base64(self): with pytest.raises(UnparseableSourcemap): fetch_sourcemap('data:application/json;base64,xxx')
def test_garbage_json(self): responses.add(responses.GET, 'http://example.com', body='xxxx', content_type='application/json') with pytest.raises(UnparseableSourcemap): fetch_sourcemap('http://example.com')