Make sure the update method uses ``auto_update`` columns correctly.
(self)
| 616 | self.assertGreater(row.modified_on, existing_modified_on) |
| 617 | |
| 618 | def test_update(self): |
| 619 | """ |
| 620 | Make sure the update method uses ``auto_update`` columns correctly. |
| 621 | """ |
| 622 | # Insert a row for us to update |
| 623 | AutoUpdateTable.insert(AutoUpdateTable(name="test")).run_sync() |
| 624 | |
| 625 | data = ( |
| 626 | AutoUpdateTable.select( |
| 627 | AutoUpdateTable.name, AutoUpdateTable.modified_on |
| 628 | ) |
| 629 | .first() |
| 630 | .run_sync() |
| 631 | ) |
| 632 | |
| 633 | assert data is not None |
| 634 | |
| 635 | self.assertDictEqual( |
| 636 | data, |
| 637 | {"name": "test", "modified_on": None}, |
| 638 | ) |
| 639 | |
| 640 | # Update the row |
| 641 | AutoUpdateTable.update( |
| 642 | {AutoUpdateTable.name: "test 2"}, force=True |
| 643 | ).run_sync() |
| 644 | |
| 645 | # Retrieve the row |
| 646 | updated_row = ( |
| 647 | AutoUpdateTable.select( |
| 648 | AutoUpdateTable.name, AutoUpdateTable.modified_on |
| 649 | ) |
| 650 | .first() |
| 651 | .run_sync() |
| 652 | ) |
| 653 | assert updated_row is not None |
| 654 | self.assertIsInstance(updated_row["modified_on"], datetime.datetime) |
| 655 | self.assertEqual(updated_row["name"], "test 2") |
| 656 | |
| 657 | |
| 658 | ############################################################################### |
nothing calls this directly
no test coverage detected