def test_serialize_url_with_non_file_urls(self):
     project_dir = gettempdir()
     url = "http://www.spine-model.org/"
     serialized = serialize_url(url, project_dir)
     self.assertEqual(serialized, {
         "type": "url",
         "relative": False,
         "path": url
     })
 def test_serialize_url_makes_file_path_in_project_dir_relative(self):
     with NamedTemporaryFile(mode="r") as temp_file:
         url = "sqlite:///" + str(Path(temp_file.name).as_posix())
         project_dir = gettempdir()
         expected_path = str(
             Path(temp_file.name).relative_to(project_dir).as_posix())
         serialized = serialize_url(url, project_dir)
         self.assertEqual(
             serialized, {
                 "type": "file_url",
                 "relative": True,
                 "path": expected_path,
                 "scheme": "sqlite"
             })
 def test_serialize_url_keeps_file_path_not_in_project_dir_absolute(self):
     with TemporaryDirectory() as project_dir:
         with NamedTemporaryFile(mode="r") as temp_file:
             expected_path = str(Path(temp_file.name).as_posix())
             if sys.platform == "win32":
                 url = "sqlite:///" + expected_path
             else:
                 url = "sqlite://" + expected_path
             serialized = serialize_url(url, project_dir)
             self.assertEqual(
                 serialized, {
                     "type": "file_url",
                     "relative": False,
                     "path": expected_path,
                     "scheme": "sqlite"
                 })