-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…more sensible
- Loading branch information
Showing
7 changed files
with
266 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/xplane_types/xplane_file/fixtures/test_resource_paths_cases_1_4.obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
I | ||
800 | ||
OBJ | ||
|
||
TEXTURE tex.png | ||
TEXTURE_LIT textures/tex.png | ||
TEXTURE_NORMAL ../textures/tex.png | ||
GLOBAL_specular 0.5 | ||
TEXTURE_DRAPED textures/tex.png | ||
TEXTURE_DRAPED_NORMAL 1.0 tex.png | ||
POINT_COUNTS 3 0 0 3 | ||
|
||
VT 1 0 1 -0 -1 -0 0.625 1 # 0 | ||
VT 1 0 -1 -0 -1 -0 0.625 0.75 # 1 | ||
VT -1 0 1 -0 -1 -0 0.375 1 # 2 | ||
|
||
IDX 0 | ||
IDX 1 | ||
IDX 2 | ||
|
||
# 0 ROOT | ||
# 1 Mesh: Plane | ||
# MESH: Plane weight: 1000 | ||
# MATERIAL: Material | ||
TRIS 0 3 | ||
|
||
# Build with Blender 2.80 (sub 75) (build b'f6cb5f54494e'). Exported with XPlane2Blender 4.1.0-beta.1+103.NO_BUILD_NUMBR |
27 changes: 27 additions & 0 deletions
27
tests/xplane_types/xplane_file/fixtures/test_resource_paths_cases_5_and_10.obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
I | ||
800 | ||
OBJ | ||
|
||
TEXTURE ../../tex.png | ||
TEXTURE_LIT none | ||
TEXTURE_NORMAL none | ||
GLOBAL_specular 0.5 | ||
TEXTURE_DRAPED textures/tex.png | ||
TEXTURE_DRAPED_NORMAL 1.0 tex.png | ||
POINT_COUNTS 3 0 0 3 | ||
|
||
VT 1 0 1 -0 -1 -0 0.625 1 # 0 | ||
VT 1 0 -1 -0 -1 -0 0.625 0.75 # 1 | ||
VT -1 0 1 -0 -1 -0 0.375 1 # 2 | ||
|
||
IDX 0 | ||
IDX 1 | ||
IDX 2 | ||
|
||
# 0 ROOT | ||
# 1 Mesh: Plane.001 | ||
# MESH: Plane.001 weight: 1000 | ||
# MATERIAL: Material | ||
TRIS 0 3 | ||
|
||
# Build with Blender 2.80 (sub 75) (build b'f6cb5f54494e'). Exported with XPlane2Blender 4.1.0-beta.1+103.NO_BUILD_NUMBR |
43 changes: 43 additions & 0 deletions
43
tests/xplane_types/xplane_file/resource_path_new_file.test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import inspect | ||
import os | ||
import sys | ||
from pathlib import Path | ||
from typing import Tuple | ||
|
||
import bpy | ||
|
||
from io_xplane2blender import xplane_config | ||
from io_xplane2blender.tests import * | ||
from io_xplane2blender.tests import test_creation_helpers | ||
|
||
__dirname__ = os.path.dirname(__file__) | ||
|
||
|
||
class TestResourcePathNewFile(XPlaneTestCase): | ||
def test_new_file_cwd_1_and_2(self) -> None: | ||
filename = inspect.stack()[0].function | ||
os.chdir(__dirname__) | ||
bpy.ops.wm.read_homefile() | ||
|
||
col = test_creation_helpers.create_datablock_collection("cwd_1_and_2") | ||
col.xplane.is_exportable_collection = True | ||
col.xplane.layer.name = filename + ".obj" | ||
col.xplane.layer.texture = "C:/tex.png" | ||
|
||
cube = test_creation_helpers.create_datablock_mesh( | ||
test_creation_helpers.DatablockInfo( | ||
"MESH", "Cube", collection="cwd_1_and_2" | ||
) | ||
) | ||
|
||
bpy.ops.export.xplane_obj(filepath=get_tmp_folder() + f"/{filename}") | ||
lines = ( | ||
(Path(get_tmp_folder()) / Path(filename).with_suffix(".obj")) | ||
.read_text() | ||
.splitlines() | ||
) | ||
|
||
self.assertTrue(lines[5].split()[1], "../../../../../../tex.png") | ||
|
||
|
||
runTestCases([TestResourcePathNewFile]) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import inspect | ||
import os | ||
import sys | ||
from pathlib import Path | ||
from typing import Tuple | ||
|
||
import bpy | ||
|
||
from io_xplane2blender import xplane_config | ||
from io_xplane2blender.tests import * | ||
from io_xplane2blender.tests import test_creation_helpers | ||
|
||
__dirname__ = Path(__file__).parent | ||
|
||
# ONBOARDING: I was pressed for time and couldn't deal with | ||
# making this environment agnostic. If you're reading this because you need to | ||
# debug this code, I'm sorry for the trouble. | ||
@unittest.skipIf( | ||
Path("C:/Users/Ted/XPlane2Blender/tests/xplane_types/xplane_file") != __dirname__, | ||
"This test is environment specific. You'll need to make it agnostic or change the paths for your computer.", | ||
) | ||
class TestResourcePaths(XPlaneTestCase): | ||
def test_resource_paths_cases_1_4(self) -> None: | ||
filename = inspect.stack()[0].function | ||
|
||
self.assertExportableRootExportEqualsFixture( | ||
filename[5:], | ||
os.path.join(__dirname__, "fixtures", f"{filename}.obj"), | ||
{"TEXTURE"}, | ||
filename, | ||
) | ||
|
||
def test_resource_paths_cases_5_and_10(self) -> None: | ||
filename = inspect.stack()[0].function | ||
|
||
self.assertExportableRootExportEqualsFixture( | ||
filename[5:], | ||
os.path.join(__dirname__, "fixtures", f"{filename}.obj"), | ||
{"TEXTURE"}, | ||
filename, | ||
) | ||
|
||
def test_errors_6_7(self) -> None: | ||
filename = inspect.stack()[0].function | ||
|
||
out = self.exportExportableRoot(filename[5:]) | ||
self.assertLoggerErrors(5) | ||
|
||
|
||
runTestCases([TestResourcePaths]) |