Esempio n. 1
0
    def test_1(self):
        entry = Entry()
        value1 = 1

        self.assertNotEquals(entry.current_value, value1)
        entry.current_value = value1
        self.assertEquals(entry.current_value, value1)
        self.assertTrue(entry.has_changed())
        self.assertEquals(entry.diff(), (None, value1))
        self.assertTrue(entry.has_changed())

        entry.receive_storage_ack()
        self.assertFalse(entry.has_changed())

        self.assertEquals(entry.current_value, value1)

        #TODO: use a more precise exception
        with self.assertRaises(Exception):
            entry.diff()

        value2 = 2
        entry.current_value = value2
        self.assertEquals(entry.current_value, value2)
        self.assertTrue(entry.has_changed())
        self.assertEquals(entry.diff(), (value1, value2))

        entry.receive_storage_ack()
        self.assertFalse(entry.has_changed())
        self.assertEquals(entry.current_value, value2)
Esempio n. 2
0
    def test_boolean(self):
        entry = Entry()
        entry.current_value = False

        self.assertTrue(entry.has_changed())
        self.assertEquals(entry.diff(), (None, False))

        entry.receive_storage_ack()
        self.assertFalse(entry.has_changed())

        entry.current_value = None
        self.assertTrue(entry.has_changed())
        self.assertEquals(entry.diff(), (False, None))