diff --git a/python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py b/python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py index e8e672bc9..dbdc38ef3 100644 --- a/python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py +++ b/python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py @@ -2,6 +2,7 @@ import json import logging +import os from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Union from uuid import uuid4 @@ -63,6 +64,11 @@ def __init__( comm_metadata = GISDocument._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__( diff --git a/python/jupytergis_lab/jupytergis_lab/notebook/tests/test_api.py b/python/jupytergis_lab/jupytergis_lab/notebook/tests/test_api.py index d6a6dc5c5..6a0a3476c 100644 --- a/python/jupytergis_lab/jupytergis_lab/notebook/tests/test_api.py +++ b/python/jupytergis_lab/jupytergis_lab/notebook/tests/test_api.py @@ -1,8 +1,26 @@ +import os import unittest from jupytergis_lab import GISDocument +class ProjectCreation(unittest.TestCase): + filename = "test.jgis" + + 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 = GISDocument(self.filename) + + assert os.path.isfile(self.filename) + + class VectorTileTests(unittest.TestCase): def setUp(self): self.doc = GISDocument()