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

[#2564] Mark catalogus as a required field on ZaakTypeconfig #1262

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

swrichards
Copy link
Collaborator

No description provided.

@swrichards swrichards force-pushed the tasks/2564-catalogus-required-on-zaaktypeconfig branch 6 times, most recently from ec1b310 to 2212d05 Compare June 19, 2024 10:19
@swrichards swrichards marked this pull request as ready for review June 19, 2024 10:20
@swrichards swrichards requested a review from pi-sigma June 19, 2024 10:20
Copy link
Contributor

@pi-sigma pi-sigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -66,3 +70,47 @@ def test_migration_0048_to_0051_multi_zgw_backend(self):
expected,
msg="Service config should have been moved to a new ZGWApiGroupConfig",
)


class TestMakeZaakTypeConfigCatalogusRequired(TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a utility class for migration tests that sets + resets the constraint checks (among other things). You don't have to use it, but take a look: https://github.com/maykinmedia/open-inwoner/blob/develop/src/open_inwoner/utils/tests/test_migrations.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. the difficulty here is that you need to test a failing migration, which the utility isn't set up for (I set out to address that in #1267).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, hadn't looked at that one, perfect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're generally happy with #1267 then I can rebase this PR on top of it and use the new-fangled utility to simplify this test.

Copy link
Collaborator Author

@swrichards swrichards Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, usage example of the failing scenario at

class TestMakeZaakTypeConfigCatalogusRequired(TestFailingMigrations):
migrate_from = "0051_drop_root_zgw_fields"
migrate_to = "0052_zaaktypeconfig_catalogus_is_required"
app = "openzaak"
def setUpBeforeMigration(self, apps):
ZaakTypeConfig = apps.get_model("openzaak", "ZaakTypeConfig")
ZaakTypeConfig.objects.create(urls=[], catalogus=None, identificatie="foobar")
def test_migration_0051_to_0052_raises_with_descriptive_exception_message(self):
with self.assertRaises(DataError) as cm:
self.attempt_migration()
self.assertEqual(
str(cm.exception),
"Your database contains 1 ZaakTypeConfig row(s) with a missing `catalogus` field."
" This field is now required: please manually update all the affected rows or re-sync"
" your ZGW objects to ensure the field is included.",
)

@swrichards
Copy link
Collaborator Author

There are two places that rely on the condition that catalogus is null and should be changed:

* https://github.com/maykinmedia/open-inwoner/blob/develop/src/open_inwoner/openzaak/models.py#L389

* https://github.com/maykinmedia/open-inwoner/blob/develop/src/open_inwoner/openzaak/managers.py#L101

Excellent catch, thanks, will address these.

@swrichards swrichards force-pushed the tasks/2564-catalogus-required-on-zaaktypeconfig branch 7 times, most recently from b1fadf1 to 688ff8c Compare June 22, 2024 08:32
This field was only optional because eSuite did not (always)
include a catalogus on its zaak types. That has since been
fixed. This commit removes some legacy behavior which assumes
that catalogus is nullable.
@swrichards swrichards force-pushed the tasks/2564-catalogus-required-on-zaaktypeconfig branch from 688ff8c to 098ed8b Compare June 24, 2024 07:13
@swrichards swrichards requested a review from pi-sigma June 24, 2024 07:35
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.17%. Comparing base (2149012) to head (098ed8b).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1262      +/-   ##
===========================================
- Coverage    95.18%   95.17%   -0.01%     
===========================================
  Files          980      981       +1     
  Lines        35687    35665      -22     
===========================================
- Hits         33969    33945      -24     
- Misses        1718     1720       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swrichards swrichards requested a review from alextreme June 24, 2024 09:46
@alextreme alextreme merged commit a847b58 into develop Jun 25, 2024
16 checks passed
@alextreme alextreme deleted the tasks/2564-catalogus-required-on-zaaktypeconfig branch June 25, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants