From 6c059b55f072b9255ab03f147aad6884e43968f7 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Mon, 11 Nov 2013 10:14:51 +0200 Subject: [PATCH] Added more tests for select expressions --- ...s.py => test_custom_select_expressions.py} | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) rename tests/aggregate/{test_lazy_select_expressions.py => test_custom_select_expressions.py} (72%) diff --git a/tests/aggregate/test_lazy_select_expressions.py b/tests/aggregate/test_custom_select_expressions.py similarity index 72% rename from tests/aggregate/test_lazy_select_expressions.py rename to tests/aggregate/test_custom_select_expressions.py index 73b1f47..7a166a0 100644 --- a/tests/aggregate/test_lazy_select_expressions.py +++ b/tests/aggregate/test_custom_select_expressions.py @@ -34,7 +34,7 @@ class TestLazyEvaluatedSelectExpressionsForAggregates(TestCase): self.Catalog = Catalog self.Product = Product - def test_assigns_aggregates(self): + def test_assigns_aggregates_insert(self): catalog = self.Catalog( name=u'Some catalog' ) @@ -49,3 +49,21 @@ class TestLazyEvaluatedSelectExpressionsForAggregates(TestCase): self.session.commit() self.session.refresh(catalog) assert catalog.net_worth == Decimal('1000') + + def test_assigns_aggregates_on_update(self): + catalog = self.Catalog( + name=u'Some catalog' + ) + self.session.add(catalog) + self.session.commit() + product = self.Product( + name=u'Some product', + price=Decimal('1000'), + catalog=catalog + ) + self.session.add(product) + self.session.commit() + product.price = Decimal('500') + self.session.commit() + self.session.refresh(catalog) + assert catalog.net_worth == Decimal('500')