Skip to content

Add functional tests for apply_default_uniqueness_rules using database-backed assertions #8285

Description

@rijulpoudel

fake_apps = FakeApps()
with patch.object(rkm, "apply_default_uniqueness_rules") as apply_rules:
rkm.apply_default_uniqueness_rules_to_disciplines(fake_apps)
apply_rules.assert_called_once_with(
discipline_without_constraint,
registry=fake_apps,
)
self.assertIs(fake_uniqueness_rule_manager.last_is_database_constraint, True)

The existing test for apply_default_uniqueness_rules_to_disciplines in
business_rules_tests.py only verifies control flow, that the outer function
calls apply_default_uniqueness_rules once. There are no tests that actually
verify the behavior end-to-end.

We need database-backed tests that confirm:

  • Uniqueness Rules are actually created in Disciplines that don't have them
  • Duplicate rules are NOT created in Disciplines that already have the rules
  • apply_default_uniqueness_rules_to_disciplines only targets Disciplines
    without existing Uniqueness Rules, skipping those that already have them

Originally posted by @melton-jason in #8225 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    MigrationPrs that contain migrationtype:testIssue indicates a needed test.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions