

def test_export_instance_deleted_columns_updated(self, _):
    'This test ensures that when building from a saved export that the new instance correctly labels the\n        old columns as advanced\n        '
    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[len(TOP_MAIN_FORM_TABLE_PROPERTIES)].selected)
    build_ids_and_versions = {
        self.app_id: 4,
    }
    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(x.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.assertEqual(len(filter((lambda c: c.is_advanced), instance.tables[0].columns)), (2 + len([x for x in MAIN_FORM_TABLE_PROPERTIES if x.is_advanced])))

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/export/tests/test_export_instance.py TestExportInstanceFromSavedInstance.test_export_instance_deleted_columns_updated/VarMisuse@154/313 `self`->`x`