Skip to content

Commit c064627

Browse files
committed
Adds tests for run_gui
1 parent ca335f6 commit c064627

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

tests/test_thorium.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
BUILTINS = dict(sys.modules['__builtin__'].__dict__)
2929

30+
GUI_FALSE = {
31+
'animatedSnap3D': False,
32+
}
3033
# =============================================================================
3134
# TEST CLASSES
3235
# =============================================================================
@@ -108,6 +111,39 @@ def test_empty(self):
108111
'string' not in sys.modules['__builtin__'].__dict__
109112
)
110113

114+
115+
class testRunGui(unittest.TestCase):
116+
"""Tests the run_gui function"""
117+
118+
# =========================================================================
119+
# TESTS
120+
# =========================================================================
121+
122+
@mock.patch('thorium._importer')
123+
def test_no_imports(self, mock_importer):
124+
"""Tests run_gui with no imports"""
125+
126+
thorium.run_gui(GUI_FALSE)
127+
128+
self.assertFalse(
129+
mock_importer.called
130+
)
131+
132+
# =========================================================================
133+
134+
@mock.patch('thorium._importer')
135+
@mock.patch('thorium.animatedSnap3D.run')
136+
def test_animated_snap_imported(self, mock_snap, mock_importer):
137+
"""Tests that animatedSnap3D is imported by default"""
138+
139+
gui_dict = dict(GUI_FALSE)
140+
gui_dict['animatedSnap3D'] = True
141+
142+
thorium.run_gui(gui_dict)
143+
144+
mock_importer.assert_called_once_with('animatedSnap3D')
145+
mock_snap.assert_called_once_with()
146+
111147
# =============================================================================
112148
# RUNNER
113149
# =============================================================================

thorium/animatedSnap3D/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
# ==============================================================================
6262

6363
# Nuke Imports
64-
import nuke
64+
try:
65+
import nuke
66+
except ImportError:
67+
pass
6568

6669
# animatedSnap3D Imports
6770
from animatedSnap3D import animated_snap

thorium/animatedSnap3D/animatedSnap3D.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
# ==============================================================================
4444

4545
# Nuke Imports
46-
import nuke
47-
from nukescripts import snap3d
46+
try:
47+
import nuke
48+
from nukescripts import snap3d
49+
except ImportError:
50+
pass
4851

4952
# ==============================================================================
5053
# EXPORTS

0 commit comments

Comments
 (0)