def test(self, mocker): """Test finding files where there are valid config/styles folders in the HOUDINI_PATH.""" mock_find = mocker.patch("hou.findDirectories") mock_glob = mocker.patch("ht.nodes.styles.manager.glob.glob") mock_dir1 = mocker.MagicMock(spec=str) mock_dir2 = mocker.MagicMock(spec=str) mock_file1 = mocker.MagicMock(spec=str) mock_file2 = mocker.MagicMock(spec=str) mock_file3 = mocker.MagicMock(spec=str) mock_find.return_value = (mock_dir1, mock_dir2) mock_glob.side_effect = ((mock_file1, mock_file2), (mock_file3,)) expected = (mock_file1, mock_file2, mock_file3) result = manager._find_files() assert result == expected calls = [ mocker.call(os.path.join(mock_dir1, "*.json")), mocker.call(os.path.join(mock_dir2, "*.json")), ] mock_glob.assert_has_calls(calls)
def test_no_dirs(self, mocker, fix_hou_exceptions): """Test finding files where there are no config/styles folders in the HOUDINI_PATH.""" mocker.patch("hou.findDirectories", side_effect=hou.OperationFailed) mock_glob = mocker.patch("ht.nodes.styles.manager.glob.glob") result = manager._find_files() assert result == () mock_glob.assert_not_called()
def test_no_dirs(self, mock_find, mock_glob): """Test finding files where there are no config/styles folders in the HOUDINI_PATH.""" def raise_error(*args, **kwargs): raise hou.OperationFailed() mock_find.side_effect = raise_error result = manager._find_files() self.assertEqual(result, ()) mock_glob.assert_not_called()
def test(self, mock_find, mock_glob): """Test finding files where there are valid config/styles folders in the HOUDINI_PATH.""" dir1 = os.path.join("/", "some", "dir1") dir2 = os.path.join("/", "some", "dir2") file1 = os.path.join(dir1, "file1.json") file2 = os.path.join(dir1, "file2.json") file3 = os.path.join(dir2, "file3.json") mock_find.return_value = (dir1, dir2) mock_glob.side_effect = ((file1, file2), (file3,)) expected = (file1, file2, file3) result = manager._find_files() self.assertEqual(result, expected) calls = [call(os.path.join(dir1, "*.json")), call(os.path.join(dir2, "*.json"))] mock_glob.assert_has_calls(calls)
def test(self, mock_find, mock_glob): """Test finding files where there are valid config/styles folders in the HOUDINI_PATH.""" dir1 = os.path.join("/", "some", "dir1") dir2 = os.path.join("/", "some", "dir2") file1 = os.path.join(dir1, "file1.json") file2 = os.path.join(dir1, "file2.json") file3 = os.path.join(dir2, "file3.json") mock_find.return_value = (dir1, dir2) mock_glob.side_effect = ((file1, file2), (file3, )) expected = (file1, file2, file3) result = manager._find_files() self.assertEqual(result, expected) calls = [ call(os.path.join(dir1, "*.json")), call(os.path.join(dir2, "*.json")) ] mock_glob.assert_has_calls(calls)