Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TP2000 1650 commodities snapshot behaviour #1379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source venv/bin/activate
3 changes: 1 addition & 2 deletions commodities/models/dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions commodities/tests/test_commodity_tree_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading