Conversation
…a fixtures DefectDojo#15869 converted Product.platform/lifecycle/origin to foreign keys and rewrote the sample-data fixtures to reference the seeded Product_Platform/Product_Lifecycle/ Product_Origin rows by pk, but did not add those rows to the fixtures. Because Product carries a tagulous TagField, tagulous re-tags every deserialised product and resolves each FK with a real SELECT, so the fixture only loaded when the 0297 seed rows were still present. Loading it into a flushed database (the demo server's reset) failed with "Product_Platform matching query does not exist", rolled the whole fixture back, and left the UI on default system settings. Add the fourteen option rows, with the same pks and values as the 0297 seed, ahead of the first dojo.product entry in both fixtures, and add a regression test that empties the three lookup tables before loaddata so the fixtures stay self-contained. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#15869 converted
Product.platform/lifecycle/originfrom choice strings to foreign keys on the newProduct_Platform/Product_Lifecycle/Product_Originlookup tables, and rewrotedefect_dojo_sample_data.jsonanddefect_dojo_sample_data_locations.jsonto reference the rows seeded by migration0297by primary key. It did not add those rows to the fixtures themselves.Productcarries a tagulousTagField, so tagulous wraps the deserializer and its_retag_to_originaldoesgetattr(obj, field.name)on every non-M2M field, which resolves each foreign key with a realSELECTwhile the fixture is still being read. The option rows therefore have to exist in the database before the firstdojo.productentry is deserialised. On a freshly migrated database they do, sounittests/test_sample_data.pykept passing. On a database whose tables were emptied after migrating (manage.py flush, which is what the community demo server does before reloading the sample data)loaddatafails with:Because
loaddatais atomic the whole fixture rolls back,System_Settingsis never created either, and the UI shows the "Unable to load system settings from database ... Default values are being used" banner.This PR adds the fourteen option rows (five platforms, three lifecycles, six origins) to both fixtures, with exactly the primary keys,
value,name,iconanddisplay_orderthe0297seed produces, placed ahead of the firstdojo.productentry. On a seeded database they update in place with identical data; on a flushed database they recreate the rows. This follows the pattern the fixtures already use fordojo.development_environmentanddojo.sla_configuration. The diff is purely additive.Test results
unittests/test_sample_data.pygainstest_loaddata_is_self_contained_for_asset_attribute_options, which empties the three lookup tables beforeloaddataand then checks the persistedplatform/lifecycle/originvalues of the three sample products.Run against a freshly created test database with pure open-source settings, both with and without
DD_V3_FEATURE_LOCATIONS:test_loaddatapasses, the new test errors withProduct_Platform matching query does not exist.Ran 2 tests ... OKon both legs.Ruff 0.16.4 passes on the test file.
Documentation
No user-facing change; nothing to document.
🤖 Generated with Claude Code