Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/jupytercad_lab/jupytercad_lab/notebook/cad_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
import os
import tempfile
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
Expand Down Expand Up @@ -44,6 +45,11 @@ class CadDocument(CommWidget):
def __init__(self, path: Optional[str] = None):
comm_metadata = CadDocument._path_to_comm(path)

# Create an empty project file if it does not exist
if comm_metadata["path"] and not os.path.isfile(comm_metadata["path"]):
with open(comm_metadata["path"], "w") as fd:
fd.write("{}")

ydoc = Doc()

super().__init__(
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions python/jupytercad_lab/jupytercad_lab/notebook/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import unittest

from jupytercad_lab import CadDocument


class ProjectCreation(unittest.TestCase):
filename = "test.jcad"

def setUp(self):
if os.path.isfile(self.filename):
os.remove(self.filename)

def tearDown(self):
if os.path.isfile(self.filename):
os.remove(self.filename)

def test_creation(self):
self.doc = CadDocument(self.filename)

assert os.path.isfile(self.filename)
Loading