|
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)
specify7/specifyweb/specify/management/commands/tests/business_rules_tests.py
Lines 61 to 70 in 9d65f24
The existing test for
apply_default_uniqueness_rules_to_disciplinesinbusiness_rules_tests.pyonly verifies control flow, that the outer functioncalls
apply_default_uniqueness_rulesonce. There are no tests that actuallyverify the behavior end-to-end.
We need database-backed tests that confirm:
apply_default_uniqueness_rules_to_disciplinesonly targets Disciplineswithout existing Uniqueness Rules, skipping those that already have them
Originally posted by @melton-jason in #8225 (comment)