-
Notifications
You must be signed in to change notification settings - Fork 2
/
path_utils_test.py
54 lines (46 loc) · 2.46 KB
/
path_utils_test.py
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
"""Tests for the path utilities."""""
import unittest
import platform
from utils_rr import path_utils
class TestPathUtils(unittest.TestCase):
"""Test for the path utilities."""
@unittest.skipIf(platform.system() != "Windows", "Test only works on Windows.")
def test_normalize_drive_letter(self):
"""Test that the drive letter is normalized correctly."""
self.assertEqual(path_utils.normalize_drive_letter(
"c:/Users/peter/Documents/repositories/RenderRob/render_job_to_rss.py"),
"C:/Users/peter/Documents/repositories/RenderRob/render_job_to_rss.py")
self.assertEqual(path_utils.normalize_drive_letter(
"d:/test/file.txt"),
"D:/test/file.txt")
self.assertEqual(path_utils.normalize_drive_letter(
"e:\\test\\file.txt"),
"E:/test/file.txt")
self.assertEqual(path_utils.normalize_drive_letter(
"\\\\server\\share\\file.txt"),
"//server/share/file.txt")
self.assertEqual(path_utils.normalize_drive_letter("a"), "a")
@unittest.skipIf(platform.system() != "Windows", "Test only works on Windows.")
def test_get_rel_blend_path(self):
"""Test that the relative path to the blend file is correct."""
path = path_utils.get_rel_blend_path(
"C:/Users/peter/Nextcloud/20_prod/24_shots/SH050/SH050_render.blend",
"C:/Users/peter/Nextcloud/20_prod/24_shots")
self.assertEqual(path, "SH050\\SH050_render.blend")
path = path_utils.get_rel_blend_path('C:/something/completely/different.blend',
"C:/Users/peter/Nextcloud/20_prod/24_shots")
self.assertEqual(path.replace("\\", "/"), 'C:/something/completely/different.blend')
path = path_utils.get_rel_blend_path(
'different.blend', "C:/Users/peter/Nextcloud/20_prod/24_shots")
self.assertEqual(path, 'different.blend')
@unittest.skipIf(platform.system() != "Windows", "Test only works on Windows.")
def test_get_abs_blend_path(self):
"""Test that the absolute path to the blend file is correct."""
path = path_utils.get_abs_blend_path(
'SH050\\SH050_render.blend', 'C:/Users/peter/Nextcloud/20_prod/24_shots')
self.assertEqual(
path.replace("\\", "/"),
'C:/Users/peter/Nextcloud/20_prod/24_shots/SH050/SH050_render.blend')
path = path_utils.get_abs_blend_path(
'C:/something/completely/different.blend', 'C:/Users/peter/Nextcloud/20_prod/24_shots')
self.assertEqual(path.replace("\\", "/"), 'C:/something/completely/different.blend')