|
27 | 27 |
|
28 | 28 | BUILTINS = dict(sys.modules['__builtin__'].__dict__) |
29 | 29 |
|
| 30 | +GUI_FALSE = { |
| 31 | + 'animatedSnap3D': False, |
| 32 | +} |
30 | 33 | # ============================================================================= |
31 | 34 | # TEST CLASSES |
32 | 35 | # ============================================================================= |
@@ -108,6 +111,39 @@ def test_empty(self): |
108 | 111 | 'string' not in sys.modules['__builtin__'].__dict__ |
109 | 112 | ) |
110 | 113 |
|
| 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 | + |
111 | 147 | # ============================================================================= |
112 | 148 | # RUNNER |
113 | 149 | # ============================================================================= |
|
0 commit comments