ya2 · news · projects · code · about

e569670555e4c7ad2e28c3b0e1e3f3afaa090d73
[pmachines.git] / tests / ya2 / build / test_models.py
1 from pathlib import Path
2 import sys
3 if '' in sys.path: sys.path.remove('')
4 sys.path.append(str(Path(__file__).parent.parent.parent))
5 from os import remove, makedirs, environ
6 from os.path import exists
7 from shutil import rmtree, copy
8 from unittest import TestCase
9 from itertools import product
10 from time import time
11 from ya2.build.models import ModelsBuilder
12
13
14 class ModelsBuilderTests(TestCase):
15
16 def setUp(self):
17 self.dirs = ['box', 'domino']
18 for fmt_dir in product(['bam', 'gltf'], self.dirs):
19 rmtree('assets/models/%s/%s' % fmt_dir, ignore_errors=True)
20
21 def test_models(self):
22 if environ.get('FAST') == '1':
23 self.skipTest('skipped slow tests')
24 for fmt_dir in product(['bam', 'gltf'], self.dirs):
25 self.assertFalse(exists('assets/%s/%s' % fmt_dir))
26 start = time()
27 ModelsBuilder().build('assets/models', 1)
28 self.assertTrue(time() - start > 1.5)
29 files = [
30 'assets/models/bam/box/box.bam',
31 'assets/models/bam/box/base.dds',
32 'assets/models/bam/box/ao_metal_roughness.dds',
33 'assets/models/bam/box/normal.dds',
34 'assets/models/bam/domino/domino.bam',
35 'assets/models/bam/domino/base.dds',
36 'assets/models/bam/domino/ao_roughness_metal.dds',
37 'assets/models/bam/domino/normal.dds',
38 'assets/models/gltf/box/box.gltf',
39 'assets/models/gltf/box/base.png',
40 'assets/models/gltf/box/ao_metal_roughness.png',
41 'assets/models/gltf/box/normal.png',
42 'assets/models/gltf/domino/domino.gltf',
43 'assets/models/gltf/domino/base.png',
44 'assets/models/gltf/domino/ao_roughness_metal.png',
45 'assets/models/gltf/domino/normal.png']
46 [self.assertTrue(exists(fname)) for fname in files]
47 #start = time()
48 #ModelsBuilder().build('assets/models', 1)
49 #self.assertTrue(time() - start < 1.5) # test caching
50 #[self.assertTrue(exists(fname)) for fname in files]