Skip to content

refactor(cl): refactored factories #5953

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

florean
Copy link
Contributor

@florean florean commented Jul 12, 2025

After working a lot with the factories, I found a number of things that could be streamlined. I focused on favoring explicit over implicit when it resulted in less code, removing redundancies, and consistency.

This is best reviewed by commit, as they each represent a discrete change. Most of the important changes are in cl/search/factories.py, with the bulk of the other changes just renaming. It looks like a lot, but fortunately all the changes are in tests, so it has 100% coverage.

florean added 11 commits July 11, 2025 17:21
Move DocketFactory towards the top of the file so it can be referenced
directly.
Moved CitationWithParentsFactory to after the factory it references.
Instead of redoing OpinionClusterFactoryWithChildren, it just inherits from it.
Removes code from DocketParentMixin that is better accomplished through
SelfAttributes.  Also has the benefit of making implicit behavior explicit,
increasing readability, and reducing code.
DocketEntryWithParentsFactory is the exact same as DocketEntryFactory, so it
makes no sense to have both.
It is used in two places, one of which can use a different parent class, and
does nothing that an explicit one-liner doesn't do.
Renamed OpinionClusterWithChildrenAndParentsFactory,
OpinionClusterFactoryWithChildren, and OpinionClusterFactoryMultipleOpinions so
they end in Factory like all other factories.
Fixed all the places where RECAPDocument.document_number was being treated as an
int instead of a string.
The test test_percolate_document_on_ingestion was relying on a typing bug.  When
creating the RECAPDocument rd_2, it was correctly setting the document_number
to a string, "1".  However, when it changed the value to trigger a webhook, it
set the value to the integer 1.  This worked because 1 != "1", even though
Django converts it later to a string and the result in the database is the
same.
@mlissner
Copy link
Member

Thanks. This all looks good to me, but I'll Alberto take a more careful look. Looks really nice though.

@mlissner mlissner moved this from Journey 🎸 to Buffer Zone in Sprint (Web Team) Jul 14, 2025
@mlissner mlissner moved this from Buffer Zone to Journey 🎸 in Sprint (Web Team) Jul 14, 2025
@ERosendo ERosendo moved this from Journey 🎸 to To Do in Sprint (Web Team) Jul 14, 2025
@albertisfu albertisfu moved this from To Do to In progress in Sprint (Web Team) Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants