Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drzraf committed Sep 17, 2023
1 parent add619c commit 7cb7b3e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import unittest
import os
from tubeup.utils import sanitize_identifier, check_is_file_empty
import json
from tubeup.utils import sanitize_identifier, check_is_file_empty, strip_ip_from_meta

current_path = os.path.dirname(os.path.realpath(__file__))

def get_testfile_path(name):
return os.path.join(current_path, 'test_tubeup_files', name)

class UtilsTest(unittest.TestCase):

Expand Down Expand Up @@ -48,3 +53,14 @@ def test_check_is_file_empty_when_file_doesnt_exist(self):
FileNotFoundError,
r"^Path 'file_that_doesnt_exist.txt' doesn't exist$"):
check_is_file_empty('file_that_doesnt_exist.txt')

def test_strip_ip_from_meta(self):
with open(get_testfile_path(
'Mountain_3_-_Video_Background_HD_1080p-6iRV8liah8A.'
'info.json')
) as f:
vid_meta = json.load(f)
mod, new_meta = strip_ip_from_meta(vid_meta)
self.assertTrue(mod)
self.assertNotEqual(f.read(), json.dumps(new_meta))
self.assertNotRegex(json.dumps(new_meta), r'36\.73\.93\.234')

0 comments on commit 7cb7b3e

Please sign in to comment.