Skip to content

Commit

Permalink
Clean up cleanup test to use ButlerURI methods and not os.path
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Aug 4, 2020
1 parent 4576c89 commit 9e3051b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_datastore.py
Original file line number Diff line number Diff line change
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 9e3051b

Please sign in to comment.