当前位置: 首页>>代码示例>>Python>>正文


Python pywb.get_test_dir函数代码示例

本文整理汇总了Python中pywb.get_test_dir函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_dir函数的具体用法?Python get_test_dir怎么用?Python get_test_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_test_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_resolver_dir_wildcard

    def test_resolver_dir_wildcard(self):
        resolver = DefaultResolverMixin.make_best_resolver(os.path.join(get_test_dir(), '*', ''))

        cdx = CDXObject()
        res = resolver('example.warc.gz', cdx)
        assert len(res) == 1
        assert res[0] == os.path.join(get_test_dir(), 'warcs', 'example.warc.gz')
开发者ID:ikreymer,项目名称:pywb,代码行数:7,代码来源:test_pathresolvers.py

示例2: test_resolver_dir_wildcard_as_file_url

    def test_resolver_dir_wildcard_as_file_url(self):
        url = to_file_url(get_test_dir()) +  '/*/'
        resolver = DefaultResolverMixin.make_best_resolver(url)

        cdx = CDXObject()
        res = resolver('example.warc.gz', cdx)
        assert len(res) == 1
        assert res[0] == os.path.abspath(os.path.join(get_test_dir(), 'warcs', 'example.warc.gz'))
开发者ID:ikreymer,项目名称:pywb,代码行数:8,代码来源:test_pathresolvers.py

示例3: setup_class

    def setup_class(cls):
        super(TestZipnumAutoDir, cls).setup_class('config_test.yaml')

        manager(['init', 'testzip'])

        cls.archive_dir = os.path.join(cls.root_dir, '_test_colls', 'testzip', 'archive')
        cls.index_dir = os.path.join(cls.root_dir, '_test_colls', 'testzip', 'indexes')

        zip_cdx = os.path.join(get_test_dir(), 'zipcdx')

        shutil.copy(os.path.join(zip_cdx, 'zipnum-sample.idx'), cls.index_dir)
        shutil.copy(os.path.join(zip_cdx, 'zipnum-sample.cdx.gz'), cls.index_dir)
        shutil.copy(os.path.join(zip_cdx, 'zipnum-sample.loc'), cls.index_dir)

        shutil.copy(os.path.join(get_test_dir(), 'warcs', 'iana.warc.gz'), cls.archive_dir)
开发者ID:ikreymer,项目名称:pywb,代码行数:15,代码来源:test_zipnum_auto_dir.py

示例4: test_cdxj_resolve_revisit_2

def test_cdxj_resolve_revisit_2():
    # Resolve Revisit -- cdxj minimal -- output also json
    results = cdx_ops_test_data(
        url="http://example.com/?example=1",
        sources=[get_test_dir() + "cdxj/example-no-digest.cdxj"],
        resolveRevisits=True,
    )
    assert len(results) == 2
    assert dict(results[0]) == {
        "urlkey": "com,example)/?example=1",
        "timestamp": "20140103030321",
        "url": "http://example.com?example=1",
        "length": "1043",
        "filename": "example.warc.gz",
        "offset": "333",
        "orig.length": "-",
        "orig.offset": "-",
        "orig.filename": "-",
    }

    assert dict(results[1]) == {
        "urlkey": "com,example)/?example=1",
        "timestamp": "20140103030341",
        "url": "http://example.com?example=1",
        "length": "553",
        "filename": "example.warc.gz",
        "mime": "warc/revisit",
        "offset": "1864",
        "orig.length": "-",
        "orig.offset": "-",
        "orig.filename": "-",
    }
开发者ID:eriknstr,项目名称:pywb,代码行数:32,代码来源:test_cdxops.py

示例5: test_zip_prefix_load

def test_zip_prefix_load():

    tmpdir = tempfile.mkdtemp()
    try:
        shutil.copy(test_zipnum, tmpdir)
        shutil.copy(get_test_dir() + 'zipcdx/zipnum-sample.cdx.gz',
                    os.path.join(tmpdir, 'zipnum'))

        config={}
        config['shard_index_loc'] = dict(match='(.*)',
                                         replace=r'\1')
        server = CDXServer(os.path.join(tmpdir, 'zipnum-sample.idx'),
                           config=config)


        # Test Page Count
        results = server.load_cdx(url='iana.org/',
                                  matchType='domain',
                                  showNumPages=True)

        results = list(results)
        assert len(results) == 1, results
        assert json.loads(results[0]) == {"blocks": 38, "pages": 4, "pageSize": 10}


        # Test simple query
        results = server.load_cdx(url='iana.org/')
        results = list(results)
        assert len(results) ==3, results
        assert '20140126200624' in results[0]
        assert '20140127171238' in results[1]
        assert 'warc/revisit' in results[2]

    finally:
        shutil.rmtree(tmpdir)
开发者ID:akeprojecta,项目名称:pywb,代码行数:35,代码来源:test_zipnum.py

示例6: test_dash_default_max

    def test_dash_default_max(self):
        headers = {'Content-Type': 'application/dash+xml'}
        with open(os.path.join(get_test_dir(), 'text_content', 'sample_dash.mpd'), 'rt') as fh:
            content = fh.read()

        headers, gen, is_rw = self.rewrite_record(headers, content, ts='201701oe_',
                                                  url='http://example.com/path/manifest.mpd')

        assert headers.headers == [('Content-Type', 'application/dash+xml')]

        filtered = """\
<?xml version='1.0' encoding='UTF-8'?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" mediaPresentationDuration="PT0H3M1.63S" minBufferTime="PT1.5S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
  <Period duration="PT0H3M1.63S" start="PT0S">
    <AdaptationSet>
      <ContentComponent contentType="video" id="1" />
      <Representation bandwidth="4190760" codecs="avc1.640028" height="1080" id="1" mimeType="video/mp4" width="1920">
        <BaseURL>http://example.com/video-10.mp4</BaseURL>
        <SegmentBase indexRange="674-1149">
          <Initialization range="0-673" />
        </SegmentBase>
      </Representation>
      </AdaptationSet>
    <AdaptationSet>
      <ContentComponent contentType="audio" id="2" />
      <Representation bandwidth="255236" codecs="mp4a.40.2" id="7" mimeType="audio/mp4" numChannels="2" sampleRate="44100">
        <BaseURL>http://example.com/audio-2.mp4</BaseURL>
        <SegmentBase indexRange="592-851">
          <Initialization range="0-591" />
        </SegmentBase>
      </Representation>
      </AdaptationSet>
  </Period>
</MPD>"""
        assert b''.join(gen).decode('utf-8') == filtered
开发者ID:ikreymer,项目名称:pywb,代码行数:35,代码来源:test_content_rewriter.py

示例7: test_path_index_resolvers

    def test_path_index_resolvers(self):
        path = os.path.join(get_test_dir(), 'text_content', 'pathindex.txt')
        path_index = PathIndexResolver(path)

        cdx = CDXObject()
        assert list(path_index('example.warc.gz', cdx)) == ['invalid_path', 'sample_archive/warcs/example.warc.gz']
        assert list(path_index('iana.warc.gz', cdx)) == ['sample_archive/warcs/iana.warc.gz']
        assert list(path_index('not-found.gz', cdx)) == []
开发者ID:ikreymer,项目名称:pywb,代码行数:8,代码来源:test_pathresolvers.py

示例8: test_local_no_head_only_title

def test_local_no_head_only_title():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample_no_head_2.html',
                                         urlrewriter,
                                         head_insert_func,
                                         'com,example,test)/')

    # wombat insert added
    assert '<script src="/static/__pywb/wombat.js"> </script>' in buff
开发者ID:chdorner,项目名称:pywb,代码行数:8,代码来源:test_rewrite_live.py

示例9: setup_class

    def setup_class(cls):
        super(MementoOverrideTests, cls).setup_class()

        # Load expected link headers
        MementoOverrideTests.link_header_data = None
        with open(to_path(get_test_dir() + '/text_content/link_headers.yaml')) as fh:
            MementoOverrideTests.link_header_data = yaml.load(fh)

        MementoOverrideTests.orig_get_timegate_links = MementoIndexSource.get_timegate_links
开发者ID:ikreymer,项目名称:pywb,代码行数:9,代码来源:testutils.py

示例10: test_local_unclosed_script

def test_local_unclosed_script():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample_unclosed_script.html',
                                         urlrewriter,
                                         head_insert_func,
                                         'com,example,test)/')

    # wombat insert added
    assert '<head><script src="/static/__pywb/wombat.js"> </script>' in buff, buff

    # JS location and JS link rewritten
    assert 'window.WB_wombat_location = "/pywb/20131226101010/http:\/\/example.com/dynamic_page.html";\n}\n</script>' in buff, buff
开发者ID:ronos,项目名称:pywb,代码行数:11,代码来源:test_rewrite_live.py

示例11: test_local_no_head_banner_only

def test_local_no_head_banner_only():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample_no_head.html',
                                         bn_urlrewriter,
                                         head_insert_func,
                                         'com,example,test)/')

    # wombat insert added
    assert '<script src="/static/__pywb/wombat.js"> </script>' in buff

    # location NOT rewritten
    assert 'window.location = "/other.html"' in buff

    # link NOT rewritten
    assert '"another.html"' in buff
开发者ID:chdorner,项目名称:pywb,代码行数:14,代码来源:test_rewrite_live.py

示例12: test_local_banner_only_no_rewrite

def test_local_banner_only_no_rewrite():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample.html',
                                         bn_urlrewriter,
                                         head_insert_func,
                                         'com,example,test)/')

    # wombat insert added
    assert '<head><script src="/static/__pywb/wombat.js"> </script>' in buff

    # JS location NOT rewritten, JS link NOT rewritten
    assert 'window.location = "http:\/\/example.com/dynamic_page.html"' in buff, buff

    # link NOT rewritten
    assert '"another.html"' in buff
开发者ID:chdorner,项目名称:pywb,代码行数:14,代码来源:test_rewrite_live.py

示例13: test_local_2_no_rewrite

def test_local_2_no_rewrite():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample.html',
                                         urlrewriter,
                                         head_insert_func,
                                         'example,example,test,norewrite)/')

    # wombat insert added
    assert '<script src="/static/__pywb/wombat.js"> </script>' in buff

    # JS location NOT rewritten, JS link NOT rewritten
    assert 'window.location = "http:\/\/example.com/dynamic_page.html"' in buff

    # still link rewrite in HTML
    assert '"/pywb/20131226101010/http://example.com/some/path/another.html"' in buff
开发者ID:chdorner,项目名称:pywb,代码行数:14,代码来源:test_rewrite_live.py

示例14: test_local_1

def test_local_1():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample.html',
                                         urlrewriter,
                                         head_insert_func,
                                         'example,example,test,all)/')

    # wombat insert added
    assert '<head><script src="/static/__pywb/wombat.js"> </script>' in buff, buff

    # JS location and JS link rewritten
    assert 'window.WB_wombat_location = "/pywb/20131226101010/http:\/\/example.com/dynamic_page.html"' in buff

    # link rewritten
    assert '"/pywb/20131226101010/http://example.com/some/path/another.html"' in buff
开发者ID:chdorner,项目名称:pywb,代码行数:14,代码来源:test_rewrite_live.py

示例15: test_local_no_head

def test_local_no_head():
    status_headers, buff = get_rewritten(get_test_dir() + 'text_content/sample_no_head.html',
                                         urlrewriter,
                                         head_insert_func,
                                         'com,example,test)/')

    # wombat insert added
    assert '<script src="/static/__pywb/wombat.js"> </script>' in buff, buff

    # location rewritten
    assert 'window.WB_wombat_location = "/other.html"' in buff, buff

    # link rewritten
    assert '"/pywb/20131226101010/http://example.com/some/path/another.html"' in buff, buff
开发者ID:chdorner,项目名称:pywb,代码行数:14,代码来源:test_rewrite_live.py


注:本文中的pywb.get_test_dir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。