def test_hls_segment_shape(self): self.assertTrue( shaper.hls_segment_rule_rewrite( shaper.parse_hls_rules("1000k~e400"), self.v_playlist_1000k, self.v_playlist_1000k, {}) == shaper.generate_status(400)) self.assertTrue( shaper.hls_segment_rule_rewrite( shaper.parse_hls_rules("1000k.s0~e404"), self.v_playlist_1000k, self.s0_1000k, {}) == shaper.generate_status(404)) self.assertTrue( shaper.hls_segment_rule_rewrite( shaper.parse_hls_rules("1000k.s1~e404"), self.v_playlist_1000k, self.s0_1000k, {}) == None) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules( "1000k.s0~net100.loss10"), self.v_playlist_1000k, self.s0_1000k_mock, {}, mock_shape_segment=True) != None) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules( "1000k.*~net100.loss10"), self.v_playlist_1000k, self.s0_1000k_mock, {}, mock_shape_segment=True) != None) self.assertRaises(ValueError, shaper.hls_segment_rule_rewrite, {"1000k.*": "404"}, self.v_playlist_1000k, self.s0_1000k_mock, {})
def test_hls_segment_shape(self): self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules("1000k~e400"), self.v_playlist_1000k, self.v_playlist_1000k, {}) == shaper.generate_status(400)) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules("1000k.s0~e404"), self.v_playlist_1000k, self.s0_1000k, {}) == shaper.generate_status(404)) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules("1000k.s1~e404"), self.v_playlist_1000k, self.s0_1000k, {}) == None) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules("1000k.s0~net100.loss10"), self.v_playlist_1000k, self.s0_1000k_mock, {}, mock_shape_segment=True) != None) self.assertTrue( shaper.hls_segment_rule_rewrite(shaper.parse_hls_rules("1000k.*~net100.loss10"),self.v_playlist_1000k, self.s0_1000k_mock, {}, mock_shape_segment=True) != None) self.assertRaises(ValueError, shaper.hls_segment_rule_rewrite, {"1000k.*":"404"}, self.v_playlist_1000k, self.s0_1000k_mock, {})
def test_status_gen(self): status_url = shaper.generate_status(404) s = urlparse(status_url) self.assertTrue(s.query == "s=404")