Beispiel #1
0
    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')
Beispiel #2
0
    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
Beispiel #3
0
    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'
Beispiel #4
0
    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'
Beispiel #5
0
    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)
Beispiel #6
0
    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'
Beispiel #7
0
    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'
Beispiel #8
0
    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() == 'console.log("hello, World!")'
        assert smap_view.get_source_name(0) == "/test.js"
Beispiel #10
0
 def test_broken_base64(self):
     with pytest.raises(UnparseableSourcemap):
         fetch_sourcemap('data:application/json;base64,xxx')
Beispiel #11
0
 def test_broken_base64(self):
     with pytest.raises(UnparseableSourcemap):
         fetch_sourcemap('data:application/json;base64,xxx')
Beispiel #12
0
    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')