[chaturbate] Fixed python 3.5 bug and added regex tests

This commit is contained in:
back-to 2017-04-07 12:10:48 +00:00
parent dc95ccf7cf
commit 277d064051
2 changed files with 16 additions and 1 deletions

View File

@ -28,7 +28,7 @@ class Chaturbate(Plugin):
match = _url_re.match(self.url)
username = match.group("username")
CSRFToken = str(uuid.uuid4().get_hex().upper()[0:32])
CSRFToken = str(uuid.uuid4().hex.upper()[0:32])
headers = {
"Content-Type": "application/x-www-form-urlencoded",

View File

@ -0,0 +1,15 @@
import unittest
from streamlink.plugins.chaturbate import Chaturbate
class TestPluginChaturbate(unittest.TestCase):
def test_can_handle_url(self):
# should match
self.assertTrue(Chaturbate.can_handle_url("https://chaturbate.com/username"))
self.assertTrue(Chaturbate.can_handle_url("https://m.chaturbate.com/username"))
self.assertTrue(Chaturbate.can_handle_url("https://www.chaturbate.com/username"))
# shouldn't match
self.assertFalse(Chaturbate.can_handle_url("http://local.local/"))
self.assertFalse(Chaturbate.can_handle_url("http://localhost.localhost/"))