Skip to content

Commit

Permalink
Merge pull request #343 from lsst/tickets/DM-26229
Browse files Browse the repository at this point in the history
DM-26229: More cleanups of file usage in the presence of URI encoding
  • Loading branch information
timj committed Aug 4, 2020
2 parents ebac62f + 9e3051b commit 1d9d909
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_datastore.py
Expand Up @@ -584,9 +584,9 @@ def testIngestSymlinkOfSymlink(self):

uri = datastore.getURI(ref)
self.assertTrue(not uri.scheme or uri.scheme == "file", f"Check {uri.scheme}")
self.assertTrue(os.path.islink(uri.path))
self.assertTrue(os.path.islink(uri.ospath), f"Check {uri} is a symlink")

linkTarget = os.readlink(uri.path)
linkTarget = os.readlink(uri.ospath)
if mode == "relsymlink":
self.assertFalse(os.path.isabs(linkTarget))
else:
Expand Down Expand Up @@ -672,9 +672,8 @@ def testCleanup(self):
expectedUri = datastore.getURI(ref, predict=True)
self.assertEqual(expectedUri.fragment, "predicted")

expectedFile = expectedUri.path
self.assertTrue(expectedFile.endswith(".yaml"),
f"Is there a file extension in {expectedUri}")
self.assertEqual(expectedUri.getExtension(), ".yaml",
f"Is there a file extension in {expectedUri}")

# Try formatter that fails and formatter that fails and leaves
# a file behind
Expand All @@ -690,19 +689,20 @@ def testCleanup(self):
datastore.put(metrics, ref)

# Check that there is no file on disk
self.assertFalse(os.path.exists(expectedFile), f"Check for existence of {expectedFile}")
self.assertFalse(expectedUri.exists(), f"Check for existence of {expectedUri}")

# Check that there is a directory
self.assertTrue(os.path.exists(os.path.dirname(expectedFile)),
f"Check for existence of directory {os.path.dirname(expectedFile)}")
dir = expectedUri.dirname()
self.assertTrue(dir.exists(),
f"Check for existence of directory {dir}")

# Force YamlFormatter and check that this time a file is written
datastore.formatterFactory.registerFormatter(ref.datasetType, YamlFormatter,
overwrite=True)
datastore.put(metrics, ref)
self.assertTrue(os.path.exists(expectedFile), f"Check for existence of {expectedFile}")
self.assertTrue(expectedUri.exists(), f"Check for existence of {expectedUri}")
datastore.remove(ref)
self.assertFalse(os.path.exists(expectedFile), f"Check for existence of now removed {expectedFile}")
self.assertFalse(expectedUri.exists(), f"Check for existence of now removed {expectedUri}")


class InMemoryDatastoreTestCase(DatastoreTests, unittest.TestCase):
Expand Down

0 comments on commit 1d9d909

Please sign in to comment.