# Path: marvin_python_toolbox/management/notebook.py
# def notebook(ctx, port, enable_security, spark_conf, allow_root):
#     notebookdir = os.path.join(ctx.obj['base_path'], 'notebooks')
#     command = [
#         "SPARK_CONF_DIR={0} YARN_CONF_DIR={0}".format(spark_conf if spark_conf else os.path.join(os.environ["SPARK_HOME"], "conf")),
#         'jupyter', 'notebook',
#         '--notebook-dir', notebookdir,
#         '--ip', '0.0.0.0',
#         '--port', str(port),
#         '--no-browser',
#         '--config', os.path.join(os.environ["MARVIN_TOOLBOX_PATH"], 'extras', 'notebook_extensions', 'jupyter_notebook_config.py')
#     ]
# 
#     command.append("--NotebookApp.token=") if not enable_security else None
#     command.append("--allow-root") if allow_root else None
# 
#     ret = os.system(' '.join(command))
#     sys.exit(ret)
# 
# def lab(ctx, port, enable_security, spark_conf):
#     notebookdir = os.path.join(ctx.obj['base_path'], 'notebooks')
#     command = [
#         "SPARK_CONF_DIR={0} YARN_CONF_DIR={0}".format(spark_conf if spark_conf else os.path.join(os.environ["SPARK_HOME"], "conf")),
#         'jupyter-lab',
#         '--notebook-dir', notebookdir,
#         '--ip', '0.0.0.0',
#         '--port', str(port),
#         '--no-browser',
#     ]
# 
#     command.append("--NotebookApp.token=") if not enable_security else None
# 
#     ret = os.system(' '.join(command))
#     sys.exit(ret)


    import mock
    import unittest.mock as mock
import os
from marvin_python_toolbox.management.notebook import notebook, lab
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# from click.testing import CliRunner

try:
except ImportError:



class mocked_ctx(object):
    obj = {'base_path': '/tmp'}


@mock.patch('marvin_python_toolbox.management.notebook.sys')
@mock.patch('marvin_python_toolbox.management.notebook.os.system')
def test_notebook(system_mocked, sys_mocked):
    ctx = mocked_ctx()
    port = 8888
    enable_security = False
    allow_root = False
    spark_conf = '/opt/spark/conf'
    system_mocked.return_value = 1


# Path: marvin_python_toolbox/management/notebook.py
# def notebook(ctx, port, enable_security, spark_conf, allow_root):
#     notebookdir = os.path.join(ctx.obj['base_path'], 'notebooks')
#     command = [
#         "SPARK_CONF_DIR={0} YARN_CONF_DIR={0}".format(spark_conf if spark_conf else os.path.join(os.environ["SPARK_HOME"], "conf")),
#         'jupyter', 'notebook',
#         '--notebook-dir', notebookdir,
#         '--ip', '0.0.0.0',
#         '--port', str(port),
#         '--no-browser',
#         '--config', os.path.join(os.environ["MARVIN_TOOLBOX_PATH"], 'extras', 'notebook_extensions', 'jupyter_notebook_config.py')
#     ]
# 
#     command.append("--NotebookApp.token=") if not enable_security else None
#     command.append("--allow-root") if allow_root else None
# 
#     ret = os.system(' '.join(command))
#     sys.exit(ret)
# 
# def lab(ctx, port, enable_security, spark_conf):
#     notebookdir = os.path.join(ctx.obj['base_path'], 'notebooks')
#     command = [
#         "SPARK_CONF_DIR={0} YARN_CONF_DIR={0}".format(spark_conf if spark_conf else os.path.join(os.environ["SPARK_HOME"], "conf")),
#         'jupyter-lab',
#         '--notebook-dir', notebookdir,
#         '--ip', '0.0.0.0',
#         '--port', str(port),
#         '--no-browser',
#     ]
# 
#     command.append("--NotebookApp.token=") if not enable_security else None
# 
#     ret = os.system(' '.join(command))
#     sys.exit(ret)


# Path: tests/management/test_notebook.py
    import mock
    import unittest.mock as mock
import os
from marvin_python_toolbox.management.notebook import notebook, lab

#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# from click.testing import CliRunner

try:
except ImportError:



class mocked_ctx(object):
    obj = {'base_path': '/tmp'}


@mock.patch('marvin_python_toolbox.management.notebook.sys')
@mock.patch('marvin_python_toolbox.management.notebook.os.system')
def test_notebook(system_mocked, sys_mocked):
    ctx = mocked_ctx()
    port = 8888
    enable_security = False
    allow_root = False
    spark_conf = '/opt/spark/conf'
    system_mocked.return_value = 1


    notebook(ctx, port, enable_security, spark_conf, allow_root)