Esempio n. 1
0
    def test_modification_tracking(self):
        """Test that record modifications are tracked."""
        fake_modifications = {'drink': 'Dr. Pepper', 'city': 'New York'}

        record = Record(['name', 'drink', 'city'],
                        ['David', 'Coffee', 'Hamburg'])
        record.name = 'David'  # should not be flagged as it is the same value
        record.drink = 'Dr. Pepper'
        record.city = 'New York'

        self.assertEqual(fake_modifications, record.modifications())
Esempio n. 2
0
    def test_dirty_record_flagging(self):
        """Test that a record gets flagged as dirty when you change its value."""
        assert_name = 'David'
        assert_drink = 'Coffee'

        # setting the same value should not flag as dirty
        record = Record(['name', 'drink'], [assert_name, assert_drink])
        record.name = 'David'
        self.assertFalse(record.is_dirty)

        # ... again for dict access
        record = Record(['name', 'drink'], [assert_name, assert_drink])
        record['name'] = 'David'
        self.assertFalse(record.is_dirty)

        # now do change the value
        record = Record(['name', 'drink'], [assert_name, assert_drink])
        record.name = 'Caspar'
        self.assertTrue(record.is_dirty)

        record = Record(['name', 'drink'], [assert_name, assert_drink])
        record['name'] = 'Caspar'
        self.assertTrue(record.is_dirty)