예제 #1
0
    def test_dirty_fields(self):
        tm = TestModel()
        # initial state shouldn't be dirty
        self.assertEqual(tm.get_dirty_fields(), {})

        # changing values should flag them as dirty
        tm.boolean = False
        tm.characters = 'testing'
        self.assertEqual(tm.get_dirty_fields(), {
            'boolean': True,
            'characters': ''
        })

        # resetting them to original values should unflag
        tm.boolean = True
        self.assertEqual(tm.get_dirty_fields(), {
            'characters': ''
        })
예제 #2
0
 def test_sweeping(self):
     tm = TestModel()
     tm.boolean = False
     tm.characters = 'testing'
     self.assertEqual(tm.get_dirty_fields(), {
         'boolean': True,
         'characters': ''
     })
     tm.save()
     self.assertEqual(tm.get_dirty_fields(), {})