added coveraged around utils
Browse files- tests/test_utils.py +21 -0
tests/test_utils.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
from __future__ import unicode_literals
|
4 |
+
from nose.tools import eq_
|
5 |
+
from pytube import utils
|
6 |
+
|
7 |
+
|
8 |
+
class TestUtils(object):
|
9 |
+
blob = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
|
10 |
+
|
11 |
+
def test_truncate(self):
|
12 |
+
"""Truncate string works as expected"""
|
13 |
+
truncated = utils.truncate(self.blob, 11)
|
14 |
+
eq_(truncated, 'Lorem ipsum')
|
15 |
+
|
16 |
+
def test_safe_filename(self):
|
17 |
+
"""Unsafe characters get stripped from generated filename"""
|
18 |
+
eq_(utils.safe_filename("abc1245$$"), "abc1245")
|
19 |
+
eq_(utils.safe_filename("abc##"), "abc")
|
20 |
+
eq_(utils.safe_filename("abc:foo"), "abc -foo")
|
21 |
+
eq_(utils.safe_filename("abc_foo"), "abc foo")
|