mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 23:18:40 +00:00
test(stock): isolate the disabled attribute fixtures
The test disabled the shared `Test Size` Item Attribute. On version-15 `FrappeTestCase` rolls back once per class instead of once per test, so the flag stayed visible for the rest of `TestItem` and broke the seven tests that build a variant from that attribute. Build a dedicated attribute and template instead. Nothing the test writes is reachable from another test, on either branch, so no cleanup is needed.
This commit is contained in:
@@ -361,12 +361,33 @@ class TestItem(FrappeTestCase):
|
||||
frappe.db.rollback()
|
||||
|
||||
def test_disabled_attribute_blocks_only_attribute_changes(self):
|
||||
frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)
|
||||
frappe.delete_doc_if_exists("Item", "_Test Disabled Attribute Template-L", force=1)
|
||||
frappe.delete_doc_if_exists("Item", "_Test Disabled Attribute Template", force=1)
|
||||
frappe.delete_doc_if_exists("Item Attribute", "_Test Disabled Size", force=1)
|
||||
|
||||
variant = create_variant("_Test Variant Item", {"Test Size": "Large"})
|
||||
attribute = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Item Attribute",
|
||||
"attribute_name": "_Test Disabled Size",
|
||||
"item_attribute_values": [
|
||||
{"attribute_value": "Large", "abbr": "L"},
|
||||
{"attribute_value": "Small", "abbr": "S"},
|
||||
],
|
||||
}
|
||||
).insert()
|
||||
|
||||
template = make_item(
|
||||
"_Test Disabled Attribute Template",
|
||||
{
|
||||
"has_variants": 1,
|
||||
"variant_based_on": "Item Attribute",
|
||||
"attributes": [{"attribute": attribute.name}],
|
||||
},
|
||||
)
|
||||
|
||||
variant = create_variant(template.name, {attribute.name: "Large"})
|
||||
variant.save()
|
||||
|
||||
attribute = frappe.get_doc("Item Attribute", "Test Size")
|
||||
attribute.disabled = 1
|
||||
attribute.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user