Skip to content

Commit

Permalink
better testing
Browse files Browse the repository at this point in the history
  • Loading branch information
4c0d3r authored and 4c0d3r committed Mar 2, 2022
1 parent 9f050b9 commit 5b0ccdd
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion namer_watchdog_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def test_handler_collisions_success(self, mock_poster, mock_response):
'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!(1).mp4')
output2 = MP4(outputfile2)
self.assertEqual(output2.get('\xa9nam'), ['Carmela Clutch: Fabulous Anal 3-Way!'])
self.assertEqual(len(list(config.failed_dir.iterdir())), 0)
self.assertEqual(len(list(config.watch_dir.iterdir())), 0)



Expand Down Expand Up @@ -111,11 +113,13 @@ def test_eventlisterner_success(self, mock_poster, mock_response):
'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!.mp4')
output = MP4(outputfile)
self.assertEqual(output.get('\xa9nam'), ['Carmela Clutch: Fabulous Anal 3-Way!'])
self.assertEqual(len(list(config.failed_dir.iterdir())), 0)
self.assertEqual(len(list(config.watch_dir.iterdir())), 0)


@patch('namer_metadataapi.__get_response_json_object')
@patch('namer.get_poster')
def test_handler_deeply_nested_success(self, mock_poster, mock_response):
def test_handler_deeply_nested_success_no_dirname(self, mock_poster, mock_response):
"""
Test the handle function works for a directory.
"""
Expand Down Expand Up @@ -143,6 +147,38 @@ def test_handler_deeply_nested_success(self, mock_poster, mock_response):
outputfile2 = ( config.dest_dir / 'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!' /
'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!(1).mp4')
validate_mp4_tags(self, outputfile2)
self.assertEqual(len(list(config.failed_dir.iterdir())), 0)
self.assertEqual(len(list(config.watch_dir.iterdir())), 0)


@patch('namer_metadataapi.__get_response_json_object')
@patch('namer.get_poster')
def test_handler_deeply_nested_success(self, mock_poster, mock_response):
"""
Test the handle function works for a directory.
"""
with tempfile.TemporaryDirectory(prefix="test") as tmpdir:
tempdir = Path(tmpdir)
config = make_locations(tempdir)
config.prefer_dir_name_if_available = True
config.write_namer_log = True
config.del_other_files = False
config.min_file_size = 0
watcher = create_watcher(config)
watcher.start()
targets = [
new_ea(config.watch_dir / "EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way", use_dir=True),
]
prepare(targets, mock_poster, mock_response)
wait_until_processed(config)
watcher.stop()
self.assertFalse(targets[0].file.exists())
self.assertEqual(len(list(config.work_dir.iterdir())),0)
outputfile = ( config.dest_dir / 'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!' /
'EvilAngel - 2022-01-03 - Carmela Clutch Fabulous Anal 3-Way!.mp4')
validate_mp4_tags(self, outputfile)
self.assertEqual(len(list(config.failed_dir.iterdir())), 0)
self.assertEqual(len(list(config.watch_dir.iterdir())), 0)


@patch('namer_metadataapi.__get_response_json_object')
Expand Down

0 comments on commit 5b0ccdd

Please sign in to comment.