mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-07-20 13:38:49 -04:00
fix failing tests
This commit is contained in:
parent
3c27132aaa
commit
e7d2273856
2 changed files with 11 additions and 10 deletions
|
@ -322,8 +322,8 @@ class BrozzlerWorker:
|
||||||
|
|
||||||
def _already_fetched(self, page, ydl_fetches):
|
def _already_fetched(self, page, ydl_fetches):
|
||||||
if ydl_fetches:
|
if ydl_fetches:
|
||||||
for txn in final_bounces(ydl_fetches, page.url):
|
for fetch in ydl.final_bounces(ydl_fetches, page.url):
|
||||||
if (txn['method'] == 'GET' and txn['status_code'] == 200):
|
if (fetch['method'] == 'GET' and fetch['response_code'] == 200):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import threading
|
||||||
import os
|
import os
|
||||||
import brozzler
|
import brozzler
|
||||||
import brozzler.chrome
|
import brozzler.chrome
|
||||||
|
import brozzler.ydl
|
||||||
import logging
|
import logging
|
||||||
import yaml
|
import yaml
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -227,9 +228,8 @@ def test_proxy_down():
|
||||||
|
|
||||||
# youtube-dl fetch
|
# youtube-dl fetch
|
||||||
with tempfile.TemporaryDirectory(prefix='brzl-ydl-') as tempdir:
|
with tempfile.TemporaryDirectory(prefix='brzl-ydl-') as tempdir:
|
||||||
ydl = worker._youtube_dl(tempdir, site)
|
|
||||||
with pytest.raises(brozzler.ProxyError):
|
with pytest.raises(brozzler.ProxyError):
|
||||||
worker._try_youtube_dl(ydl, site, page)
|
brozzler.ydl.do_youtube_dl(worker, site, page)
|
||||||
|
|
||||||
# raw fetch
|
# raw fetch
|
||||||
with pytest.raises(brozzler.ProxyError):
|
with pytest.raises(brozzler.ProxyError):
|
||||||
|
@ -404,18 +404,19 @@ def test_needs_browsing():
|
||||||
page = brozzler.Page(None, {
|
page = brozzler.Page(None, {
|
||||||
'url':'http://example.com/a'})
|
'url':'http://example.com/a'})
|
||||||
|
|
||||||
spy = brozzler.worker.YoutubeDLSpy()
|
spy = brozzler.ydl.YoutubeDLSpy()
|
||||||
spy.transactions.append({
|
spy.fetches.append({
|
||||||
'url': 'http://example.com/a',
|
'url': 'http://example.com/a',
|
||||||
'method': 'HEAD',
|
'method': 'HEAD',
|
||||||
'status_code': 301,
|
'response_code': 301,
|
||||||
'response_headers': ConvenientHeaders({'Location': '/b'})})
|
'response_headers': ConvenientHeaders({'Location': '/b'})})
|
||||||
spy.transactions.append({
|
spy.fetches.append({
|
||||||
'url': 'http://example.com/b',
|
'url': 'http://example.com/b',
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
'status_code': 200,
|
'response_code': 200,
|
||||||
'response_headers': ConvenientHeaders({
|
'response_headers': ConvenientHeaders({
|
||||||
'Content-Type': 'application/pdf'})})
|
'Content-Type': 'application/pdf'})})
|
||||||
|
|
||||||
assert not brozzler.worker.BrozzlerWorker._needs_browsing(None, page, spy)
|
assert not brozzler.worker.BrozzlerWorker._needs_browsing(
|
||||||
|
None, page, spy.fetches)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue