-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlattenUtils_test.py
More file actions
63 lines (54 loc) · 2.62 KB
/
FlattenUtils_test.py
File metadata and controls
63 lines (54 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import unittest
import FlattenUtils
import os
class TestFlattenUtils(unittest.TestCase):
def test_getFilesToMigrateThrowsExceptionIfNoPathProvided(self):
with self.assertRaises(Exception):
FlattenUtils.getFilesToMigrate("", [])
def test_getFilesToMigrateThrowsExceptionIfInvalidFolderProvided(self):
with self.assertRaises(Exception):
FlattenUtils.getFilesToMigrate("c:\\lkihaghdklhdghklagdklhadgklhakjlgjkladg", [])
def test_getFilesToMigrateThrowsExceptionIfFileNotFolderIsProvided(self):
with self.assertRaises(Exception):
FlattenUtils.getFilesToMigrate(".\\test\\1\\herewego.mp4", [])
def test_getFilesToMigrateReturnsAllFilesWhenProvidedPath(self):
path = ".\\test\\"
pwd = os.path.abspath(os.path.curdir)
expectedOutput = [
os.path.join(pwd, "test\\1\\season 1\\episodes\\s01e01.mkv"),
os.path.join(pwd, "test\\1\\herewego.mp4"),
os.path.join(pwd, "test\\1\\movie.txt"),
os.path.join(pwd, "test\\2\\movie.mkv")
]
self.assertEqual(FlattenUtils.getFilesToMigrate(path, ['.mp4', '.mkv', '.txt']), expectedOutput)
def test_getFilesToMigrateReturnsOnlyMP4WhenProvidedPathAndMP4Filter(self):
path = ".\\test\\1\\"
pwd = os.path.abspath(os.path.curdir)
expectedOutput = [
os.path.join(pwd, "test\\1\\herewego.mp4")
]
self.assertEqual(FlattenUtils.getFilesToMigrate(path, [".mp4"]), expectedOutput)
def test_getFilesToMigrateReturnsFilesFromSubfolders(self):
path = ".\\test\\1\\"
pwd = os.path.abspath(os.path.curdir)
expectedOutput = [
os.path.join(pwd, "test\\1\\season 1\\episodes\\s01e01.mkv")
]
self.assertEqual(FlattenUtils.getFilesToMigrate(path, [".mkv"]), expectedOutput)
def test_getFilesToMigrateReturnsTwoFilesFromSubfolders(self):
path = ".\\test\\"
pwd = os.path.abspath(os.path.curdir)
expectedOutput = [
os.path.join(pwd, "test\\1\\season 1\\episodes\\s01e01.mkv"),
os.path.join(pwd, "test\\2\\movie.mkv")
]
self.assertEqual(FlattenUtils.getFilesToMigrate(path, [".mkv"]), expectedOutput)
def test_getFoldersGetsAllFolders(self):
path = "test\\"
pwd = os.path.abspath(os.path.curdir)
expectedOutput = [
os.path.join(pwd, "test\\1\\season 1\\episodes"),
os.path.join(pwd, "test\\1"),
os.path.join(pwd, "test\\2"),
]
self.assertEqual(FlattenUtils.getFoldersWithVideoFiles(os.path.join(pwd, path), [".mkv", ".mp4"]), expectedOutput)