45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import unittest
|
|
import os.path
|
|
import blenderpack
|
|
|
|
class test_blenderpack_make_repo(unittest.TestCase):
|
|
|
|
helper_path = os.path.join('tests', 'test_helpers')
|
|
|
|
def test_extract_blinfo_from_file(self):
|
|
with open(os.path.join(self.helper_path, 'ivy_gen_blinfo.txt'), 'r') as f:
|
|
expectation = f.read()
|
|
|
|
reality = str(blenderpack.extract_blinfo(os.path.join(self.helper_path, 'addons', 'add_curve_ivygen.py')))
|
|
self.assertEqual(expectation, reality)
|
|
|
|
def test_extract_blinfo_from_zip(self):
|
|
with open(os.path.join(self.helper_path, 'extra_objects_blinfo.txt'), 'r') as f:
|
|
expectation = f.read()
|
|
|
|
reality = str(blenderpack.extract_blinfo(os.path.join(self.helper_path, 'addons', 'add_curve_extra_objects.zip')))
|
|
self.assertEqual(expectation, reality)
|
|
|
|
def test_extract_blinfo_from_dir(self):
|
|
with open(os.path.join(self.helper_path, 'extra_objects_blinfo.txt'), 'r') as f:
|
|
expectation = f.read()
|
|
|
|
reality = str(blenderpack.extract_blinfo(os.path.join(self.helper_path, 'addons', 'add_curve_extra_objects/')))
|
|
self.assertEqual(expectation, reality)
|
|
|
|
def test_extract_blinfo_from_nonexistent(self):
|
|
self.assertRaises(
|
|
FileNotFoundError,
|
|
lambda: blenderpack.extract_blinfo(os.path.join(self.helper_path, 'addons', 'notathing'))
|
|
)
|
|
|
|
|
|
def test_make_repo_valid(self):
|
|
blenderpack.make_repo(os.path.join(self.helper_path, 'addons'))
|
|
|
|
|
|
def test_make_repo_from_nonexistent(self):
|
|
blenderpack.make_repo(os.path.join(self.helper_path, 'addons'))
|