Refactor Extension and Version: explicit constructors from File #191

Merged
Oleg-Komarov merged 6 commits from refactor-models into main 2024-06-20 14:40:41 +02:00
Owner

This change solves a blocker for an upcoming drop of Version.file field:

calculating Extension.latest_version relied on having VersionFiles already
populated, but it was triggered on Version.save(), which happened before
the cross table could be populated.

One functional change is that a Version object is now created in
NewVersionView, immediately after the File is saved, and not in
NewVersionFinalizeView, as before.

Tests are rewritten to require only FileFactory, the Extension and Version
objects are created as it is done in the actual production code.
This loses a bit on the ergonomics of factories, but overall makes the state of
test objects more consistent, often simplifying the test code.

VersionFactory is no longer needed, and has been cleaned up.
ExtensionFactory is only used in construct_fake_notifications, and could also
be replaced with an in-memory object constructed manually.

This change solves a blocker for an upcoming drop of Version.file field: calculating `Extension.latest_version` relied on having `VersionFiles` already populated, but it was triggered on `Version.save()`, which happened before the cross table could be populated. One functional change is that a Version object is now created in NewVersionView, immediately after the File is saved, and not in NewVersionFinalizeView, as before. Tests are rewritten to require only FileFactory, the Extension and Version objects are created as it is done in the actual production code. This loses a bit on the ergonomics of factories, but overall makes the state of test objects more consistent, often simplifying the test code. VersionFactory is no longer needed, and has been cleaned up. ExtensionFactory is only used in construct_fake_notifications, and could also be replaced with an in-memory object constructed manually.
Oleg-Komarov force-pushed refactor-models from af9de1b851 to c90aa6d93c 2024-06-18 19:13:58 +02:00 Compare
Oleg-Komarov force-pushed refactor-models from c90aa6d93c to 6d8fd61b23 2024-06-18 19:50:21 +02:00 Compare
Oleg-Komarov added 1 commit 2024-06-20 12:25:54 +02:00
Oleg-Komarov added 1 commit 2024-06-20 12:37:02 +02:00
Oleg-Komarov added 1 commit 2024-06-20 12:51:56 +02:00
Oleg-Komarov changed title from WIP: Refactor Extension and Version: explicit constructors from File to Refactor Extension and Version: explicit constructors from File 2024-06-20 12:52:07 +02:00
Oleg-Komarov added 1 commit 2024-06-20 13:56:39 +02:00
Oleg-Komarov added 1 commit 2024-06-20 14:33:34 +02:00
Anna Sirota approved these changes 2024-06-20 14:38:56 +02:00
Anna Sirota left a comment
Owner

LGTM

LGTM
Oleg-Komarov merged commit ac49e9d5f6 into main 2024-06-20 14:40:41 +02:00
Oleg-Komarov deleted branch refactor-models 2024-06-20 14:40:41 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/extensions-website#191
No description provided.