Skip to content

Commit

Permalink
Convert test to use UUID instead of int
Browse files Browse the repository at this point in the history
  • Loading branch information
natelust committed Jun 27, 2023
1 parent 498258d commit a2805b3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

import os.path
import unittest
import uuid

from lsst.daf.butler import (
DataCoordinate,
DatasetId,
DatasetRef,
DatasetType,
DimensionGraph,
Expand All @@ -41,6 +43,8 @@

PlaceHolder = StorageClass("PlaceHolder")

REFUUID = DatasetId(int=uuid.uuid4().int)


class TestFileTemplates(unittest.TestCase):
"""Test creation of paths from templates."""
Expand All @@ -66,7 +70,7 @@ def makeDatasetRef(
StorageClass(storageClassName),
parentStorageClass=parentStorageClass,
)
return DatasetRef(datasetType, dataId, id=1, run=run, conform=conform)
return DatasetRef(datasetType, dataId, id=REFUUID, run=run, conform=conform)

def setUp(self):
self.universe = DimensionUniverse()
Expand Down Expand Up @@ -104,19 +108,19 @@ def testBasic(self):
)

# Check that the id is sufficient without any other information.
self.assertTemplate("{id}", "1", self.makeDatasetRef("calexp", run="run2"))
self.assertTemplate("{id}", str(REFUUID), self.makeDatasetRef("calexp", run="run2"))

self.assertTemplate("{run}/{id}", "run2/1", self.makeDatasetRef("calexp", run="run2"))
self.assertTemplate("{run}/{id}", f"run2/{str(REFUUID)}", self.makeDatasetRef("calexp", run="run2"))

self.assertTemplate(
"fixed/{id}",
"fixed/1",
f"fixed/{str(REFUUID)}",
self.makeDatasetRef("calexp", run="run2"),
)

self.assertTemplate(
"fixed/{id}_{physical_filter}",
"fixed/1_Most_Amazing_U_Filter_Ever",
f"fixed/{str(REFUUID)}_Most_Amazing_U_Filter_Ever",
self.makeDatasetRef("calexp", run="run2"),
)

Expand Down

0 comments on commit a2805b3

Please sign in to comment.