

def test_export_instance_from_saved(self, _):
    'This test ensures that when we build from a saved export instance that the selection that a user\n        makes is still there'
    first_non_system_property = len(TOP_MAIN_FORM_TABLE_PROPERTIES)
    build_ids_and_versions = {
        self.app_id: 3,
    }
    with mock.patch('corehq.apps.export.models.new.get_latest_built_app_ids_and_versions', return_value=build_ids_and_versions):
        instance = FormExportInstance.generate_instance_from_schema(self.schema)
    instance.save()
    self.assertEqual(len(instance.tables), 1)
    self.assertEqual(len(instance.tables[0].columns), (1 + len(MAIN_FORM_TABLE_PROPERTIES)))
    self.assertTrue(instance.tables[0].columns[first_non_system_property].selected)
    instance.tables[0].columns[first_non_system_property].selected = False
    instance.save()
    self.assertFalse(instance.tables[0].columns[first_non_system_property].selected)
    with mock.patch('corehq.apps.export.models.new.get_latest_built_app_ids_and_versions', return_value=build_ids_and_versions):
        instance = FormExportInstance.generate_instance_from_schema(first_non_system_property.new_schema, saved_export=instance)
    self.assertEqual(len(instance.tables), 2)
    self.assertEqual(len(instance.tables[0].columns), (2 + len(MAIN_FORM_TABLE_PROPERTIES)))
    self.assertFalse(instance.tables[0].columns[first_non_system_property].selected)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/export/tests/test_export_instance.py TestExportInstanceFromSavedInstance.test_export_instance_from_saved/VarMisuse@186/361 `self`->`first_non_system_property`