home · contact · privacy
Cache DB objects to ensure we do not accidentally edit clones.
[plomtask] / tests / days.py
index 81dbcf58c0cf3d4215044809a3851017fbfa169e..2e2ef50cbe85ae6ff9fd01edd802417a7122598f 100644 (file)
@@ -33,7 +33,7 @@ class TestsSansDB(TestCase):
 
 
 class TestsWithDB(TestCaseWithDB):
-    """Days module tests not requiring DB setup."""
+    """Tests requiring DB, but not server setup."""
 
     def test_Day_by_date(self) -> None:
         """Test Day.by_date()."""
@@ -86,6 +86,14 @@ class TestsWithDB(TestCaseWithDB):
         self.assertEqual(Day('2024-01-01').prev_date, '2023-12-31')
         self.assertEqual(Day('2023-02-28').next_date, '2023-03-01')
 
+    def test_Day_singularity(self) -> None:
+        """Test pointers made for single object keep pointing to it."""
+        day = Day('2024-01-01')
+        day.save(self.db_conn)
+        retrieved_day = Day.by_date(self.db_conn, '2024-01-01')
+        day.comment = 'foo'
+        self.assertEqual(retrieved_day.comment, 'foo')
+
 
 class TestsWithServer(TestCaseWithServer):
     """Tests against our HTTP server/handler (and database)."""