1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00
pywb/tests/test_live_rewriter.py
Ilya Kreymer aa0a019567 Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present

Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView

Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00

53 lines
2.2 KiB
Python

from .base_config_test import BaseConfigTest, fmod_sl
# ============================================================================
class TestLiveRewriter(BaseConfigTest):
@classmethod
def setup_class(cls):
super(TestLiveRewriter, cls).setup_class('config_test.yaml')
def test_live_live_1(self, fmod_sl):
headers = [('User-Agent', 'python'), ('Referer', 'http://localhost:80/live/other.example.com')]
resp = self.get('/live/{0}http://example.com/', fmod_sl, headers=headers)
assert resp.status_int == 200
def test_live_live_redirect_2(self, fmod_sl):
resp = self.get('/live/{0}http://httpbin.org/redirect-to?url=http://example.com/', fmod_sl)
assert resp.status_int == 302
def test_live_live_post(self, fmod_sl):
resp = self.post('/live/{0}httpbin.org/post', fmod_sl, {'foo': 'bar', 'test': 'abc'})
assert resp.status_int == 200
resp.charset = 'utf-8'
assert '"foo": "bar"' in resp.text
assert '"test": "abc"' in resp.text
assert resp.status_int == 200
def test_live_live_frame(self):
resp = self.testapp.get('/live/http://example.com/')
assert resp.status_int == 200
resp.charset = 'utf-8'
#assert '<iframe ' in resp.text
assert '"http://localhost:80/live/"' in resp.text, resp.text
assert '"http://example.com/"' in resp.text, resp.text
def test_live_invalid(self, fmod_sl):
resp = self.get('/live/{0}http://abcdef', fmod_sl, status=307)
resp = resp.follow(status=400)
assert resp.status_int == 400
def test_live_invalid_2(self, fmod_sl):
resp = self.get('/live/{0}@#$@#$', fmod_sl, status=307)
resp = resp.follow(status=400)
assert resp.status_int == 400
def test_live_video_info(self):
resp = self.testapp.get('/live/vi_/https://www.youtube.com/watch?v=DjFZyFWSt1M')
assert resp.status_int == 200
assert resp.content_type == 'application/vnd.youtube-dl_formats+json', resp.content_type
def test_deflate(self, fmod_sl):
resp = self.get('/live/{0}http://httpbin.org/deflate', fmod_sl)
assert b'"deflated": true' in resp.body