From 3f35b533f50293f9166af38e51d17e206aad95d0 Mon Sep 17 00:00:00 2001 From: Luisella Strona Date: Fri, 10 Jan 2025 11:45:28 +0000 Subject: [PATCH 1/2] Fixed the error found --- .envrc | 1 + commodities/models/dc.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..619fe07b6 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +source venv/bin/activate diff --git a/commodities/models/dc.py b/commodities/models/dc.py index f868981ff..e80f0664b 100644 --- a/commodities/models/dc.py +++ b/commodities/models/dc.py @@ -1600,8 +1600,7 @@ def _apply_filters(qs: TrackedModelQuerySet): goods_sids = Subquery(goods_query.values("sid")) indents_query = ( - _apply_filters(GoodsNomenclatureIndent.objects) - .with_end_date() + _apply_filters(GoodsNomenclatureIndent.objects.with_end_date()) .filter(indented_goods_nomenclature__sid__in=goods_sids) .annotate(goods_sid=F("indented_goods_nomenclature__sid")) .order_by("transaction", "validity_start") From 6ec20d938dbaa0e029be4610013e410cbcd96c93 Mon Sep 17 00:00:00 2001 From: Luisella Strona Date: Fri, 10 Jan 2025 11:49:42 +0000 Subject: [PATCH 2/2] Added test --- commodities/tests/test_commodity_tree_snapshot.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commodities/tests/test_commodity_tree_snapshot.py b/commodities/tests/test_commodity_tree_snapshot.py index 1781bcca8..d8a987511 100644 --- a/commodities/tests/test_commodity_tree_snapshot.py +++ b/commodities/tests/test_commodity_tree_snapshot.py @@ -92,3 +92,11 @@ def test_get_dependent_measures_works_with_wonky_archived_measure( assert wonky_archived_measure.generating_regulation == old_regulation assert target_commodity in commodities_collection.commodities assert target_commodity in target.commodities + + +def test_CommodityCollectionLoader(seed_database_with_indented_goods): + # Test that effective_only does not crash the code + commodities_collection = CommodityCollectionLoader(prefix="2903").load( + effective_only=True, + ) + assert len(commodities_collection.commodities) == 6