-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_integration.py
62 lines (41 loc) · 2.66 KB
/
test_integration.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
55
56
57
58
59
60
import unittest
import subprocess
import os
from testsupport import TempTestFolder
class IntegrationTest(unittest.TestCase):
def assertFileExists(self, filename):
self.assertTrue(os.path.isfile(filename), "File {} does not exist".format(filename))
class BlendomaticIntegration(IntegrationTest):
def test_export(self):
mainfile = os.path.abspath("blendomatic.py")
with TempTestFolder() as tmpfolder:
subprocess.check_call([mainfile, "export", "--filenames", "{}/*.blend".format(tmpfolder.get_tempfolder()),
"--output-folder", str(tmpfolder.get_tempfolder())])
# check if the output files have been generated
# easy export of one model
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(), "monkey.obj"))
# export of different subset of models from one file
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(), "first_cube.obj"))
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(), "second_cube.obj"))
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(), "both_cubes.obj"))
def test_bake(self):
mainfile = os.path.abspath("blendomatic.py")
with TempTestFolder() as tmpfolder:
subprocess.check_call([mainfile, "bake", "--filenames", "{}/cube.blend".format(tmpfolder.get_tempfolder()),
"--output-folder", str(tmpfolder.get_tempfolder())])
# check if the output files have been generated
# baked render of the cube
self.assertFileExists(os.path.join(tmpfolder.get_tempfolder(), "cube_bake.png"))
def test_output_same_folder_as_blend_file(self):
mainfile = os.path.abspath("blendomatic.py")
with TempTestFolder(multipleFolders=True) as tmpfolder:
# don't give an output folder option, this means
subprocess.check_call([mainfile, "export", "--filenames",
"folderA/*.blend;folderB/*.blend;"])
# check if the output files have been generated
# easy export of one model, must be in the folder the model is also located
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(),"folderA", "monkey.obj"))
# export of different subset of models from one file
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(),"folderB", "first_cube.obj"))
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(),"folderB", "second_cube.obj"))
self.assertFileExists(os.path.join( tmpfolder.get_tempfolder(),"folderB", "both_cubes.obj"))