class EventHandlingTestCase(unittest.TestCase):

    def setUp(self):
        self.store = EventStore(flush=True)
        self.agg = TestAggregate()
        self.state = self.agg._state

    def test_persist(self):
        self.agg.set_foo(1)
        self.store.persist_aggregate(self.agg)

    def test_load(self):
        self.agg.set_foo(1)
        self.store.persist_aggregate(self.agg)

        agg = self.store.load(TestAggregate, self.agg.aggregate_id)
        state = agg._state

        self.assertEqual(state.get_version(), self.state.get_version())
        self.assertEqual(state.foo, 1)
 def test_set_foo(self):
     agg = TestAggregate()
     state = agg._state
     self.assertEqual(state.foo, None)
     agg.set_foo(1)
     self.assertEqual(state.foo, 1)