@@ -207,7 +207,9 @@ def test_segments_limit_ignores_old_segment_versions(
207207
208208 # and create some older versions for the segment fixture
209209 segment .clone (is_revision = True )
210- assert Segment .objects .filter (version_of = segment ).count () == 2
210+ # With the NULL-based canonical representation, only revisions are counted here
211+ # (the canonical segment has version_of=None).
212+ assert Segment .objects .filter (version_of = segment ).count () == 1
211213 assert Segment .live_objects .count () == 1
212214
213215 url = reverse ("api-v1:projects:project-segments-list" , args = [project .id ])
@@ -1058,7 +1060,9 @@ def test_update_segment_versioned_segment(
10581060 assert response .status_code == status .HTTP_200_OK
10591061
10601062 # Now verify that a new versioned segment has been set.
1061- assert Segment .objects .filter (version_of = segment ).count () == 2
1063+ # With the NULL-based canonical representation, canonical segments have
1064+ # version_of=None, so only revisions are counted here.
1065+ assert Segment .objects .filter (version_of = segment ).count () == 1
10621066
10631067 # Now check the previously versioned segment to match former count of conditions.
10641068
@@ -1093,7 +1097,10 @@ def test_update_segment_versioned_segment_with_thrown_exception(
10931097 rule = nested_rule , property = "foo" , operator = EQUAL , value = "bar"
10941098 )
10951099
1096- assert segment .version == 1 == Segment .objects .filter (version_of = segment ).count ()
1100+ # With the NULL-based canonical representation, canonical segments have
1101+ # version_of=None, so they are not included in this count.
1102+ assert segment .version == 1
1103+ assert Segment .objects .filter (version_of = segment ).count () == 0
10971104
10981105 new_condition_property = "foo2"
10991106 new_condition_value = "bar"
@@ -1144,7 +1151,9 @@ def test_update_segment_versioned_segment_with_thrown_exception(
11441151 segment .refresh_from_db ()
11451152
11461153 # Now verify that the version of the segment has not been changed.
1147- assert segment .version == 1 == Segment .objects .filter (version_of = segment ).count ()
1154+ # The transaction should have rolled back, so no revisions should exist.
1155+ assert segment .version == 1
1156+ assert Segment .objects .filter (version_of = segment ).count () == 0
11481157
11491158
11501159@pytest .mark .parametrize (
0 commit comments