From 7cb7b3ec81782f2fef37099dc0c5ef57829f4f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Sat, 16 Sep 2023 23:38:46 -0300 Subject: [PATCH] added tests --- tests/test_utils.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 8c409d8..224b9c1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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): @@ -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')