Skip to content

Commit

Permalink
Update factories to pass their transaction through to all their track…
Browse files Browse the repository at this point in the history
…ed_model fields,

this highlights issues where synthetic fields (such as descriptions) attached to
tracked_models can break record, subrecord ordering when placed in transactions together.
  • Loading branch information
stuaxo committed Oct 25, 2021
1 parent b6f8c06 commit 27ce070
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
12 changes: 6 additions & 6 deletions common/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Meta:
)
enacting_regulation = factory.SubFactory(
RegulationFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)


Expand All @@ -266,7 +266,7 @@ class Meta:
)
enacting_regulation = factory.SubFactory(
RegulationFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)


Expand All @@ -280,7 +280,7 @@ class Meta:
)
enacting_regulation = factory.SubFactory(
RegulationFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)


Expand All @@ -294,7 +294,7 @@ class Meta:
)
enacting_regulation = factory.SubFactory(
RegulationFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)

effective_date = Dates().datetime_now
Expand All @@ -310,7 +310,7 @@ class Meta:
)
enacting_regulation = factory.SubFactory(
RegulationFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)
measure_type_id = "123456"
geographical_area_id = "GB"
Expand Down Expand Up @@ -355,7 +355,7 @@ class Meta:
)
member = factory.SubFactory(
GeographicalAreaFactory,
# FIXME synthetic-record-order make this field transaction=factory.SelfAttribute("..transaction")
transaction=factory.SelfAttribute("..transaction"),
)


Expand Down
33 changes: 1 addition & 32 deletions workbaskets/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,41 +228,10 @@ def test_user_partition_scheme_get_partition_does_not_allow_seed_after_revision(
SEED_ONLY.get_partition(status)


# FIXME synthetic-record-order:
# Factories named here have fields containing TrackedModels, prior to TP-841 these would have each
# been in their own transaction.
# This hides an issue where synthetic fields (those generated by templates such as description) are
# only relative to their own tracked_model, failing under certain circumstances, as exposed by
# TP-841 aimed to unify a factories output under one transaction.
EXCLUDE_MULTI_TRANSACTION_FACTORIES = [
"AdditionalCodeTypeMeasureTypeFactory",
"AmendmentFactory",
"ExtensionFactory",
"FootnoteAssociationMeasureFactory",
"GeographicalMembershipFactory",
"MeasureComponentFactory",
"MeasureConditionComponentFactory",
"MeasureConditionFactory",
"MeasureExcludedGeographicalAreaFactory",
"MeasureFactory",
"MeasurementFactory",
"MeasureTypeFactory",
"QuotaAssociationFactory",
"QuotaBlockingFactory",
"QuotaDefinitionFactory",
"QuotaEventFactory",
"QuotaOrderNumberFactory",
"QuotaOrderNumberOriginExclusionFactory",
"QuotaOrderNumberOriginFactory",
"QuotaSuspensionFactory",
"ReplacementFactory",
"SuspensionFactory",
"TerminationFactory",
]
FACTORIES = [
factory
for factory in factories.TrackedModelMixin.__subclasses__()
if factory.__name__ not in EXCLUDE_MULTI_TRANSACTION_FACTORIES
if factory.__name__
]


Expand Down

0 comments on commit 27ce070

Please sign in to comment.