def test_view_failed_delitem(attr):
    adata = gen_adata((10, 10))
    view = adata[5:7, :][:, :5]
    adata_hash = joblib.hash(adata)
    view_hash = joblib.hash(view)

    with pytest.raises(KeyError):
        getattr(view, attr).__delitem__("not a key")

    assert view.is_view
    assert adata_hash == joblib.hash(adata)
    assert view_hash == joblib.hash(view)
def test_accept_suggestion_with_image_region_interactions(self):
        with utils.open_file(
            os.path.join(feconf.TESTS_DATA_DIR, 'img.png'), 'rb',
            encoding=None) as f:
            original_image_content = f.read()
        fs_services.save_original_and_compressed_versions_of_image(
            'image.png', 'question_suggestions', 'skill1',
            original_image_content, 'image', True)

        question_state_dict = {
            'content': {
                'html': '<p>Text</p>',
                'content_id': 'content'
            },
            'classifier_model_id': None,
            'linked_skill_id': None,
            'interaction': {
                'answer_groups': [
                    {
                        'rule_specs': [
                            {
                                'rule_type': 'IsInRegion',
                                'inputs': {'x': 'Region1'}
                            }
                        ],
                        'outcome': {
                            'dest': None,
                            'feedback': {
                                'html': '<p>assas</p>',
                                'content_id': 'feedback_0'
                            },
                            'labelled_as_correct': True,
                            'param_changes': [],
                            'refresher_exploration_id': None,
                            'missing_prerequisite_skill_id': None
                        },
                        'training_data': [],
                        'tagged_skill_misconception_id': None
                    }
                ],
                'confirmed_unclassified_answers': [],
                'customization_args': {
                    'imageAndRegions': {
                        'value': {
                            'imagePath': 'image.png',
                            'labeledRegions': [
                                {
                                    'label': 'Region1',
                                    'region': {
                                        'regionType': 'Rectangle',
                                        'area': [
                                            [
                                                0.2644628099173554,
                                                0.21807065217391305
                                            ],
                                            [
                                                0.9201101928374655,
                                                0.8847373188405797
                                            ]
                                        ]
                                    }
                                }
                            ]
                        }
                    },
                    'highlightRegionsOnHover': {
                        'value': False
                    }
                },
                'default_outcome': {
                    'dest': None,
                    'feedback': {
                        'html': '<p>wer</p>',
                        'content_id': 'default_outcome'
                    },
                    'labelled_as_correct': False,
                    'param_changes': [],
                    'refresher_exploration_id': None,
                    'missing_prerequisite_skill_id': None
                },
                'hints': [
                    {
                        'hint_content': {
                            'html': '<p>assaas</p>',
                            'content_id': 'hint_1'
                        }
                    }
                ],
                'id': 'ImageClickInput', 'solution': None
            },
            'param_changes': [],
            'recorded_voiceovers': {
                'voiceovers_mapping': {
                    'content': {},
                    'default_outcome': {},
                    'feedback_0': {},
                    'hint_1': {}
                }
            },
            'solicit_answer_details': False,
            'card_is_checkpoint': False,
            'written_translations': {
                'translations_mapping': {
                    'content': {},
                    'default_outcome': {},
                    'feedback_0': {},
                    'hint_1': {}
                }
            },
            'next_content_id_index': 2
        }
        suggestion_dict = {
            'suggestion_id': 'skill1.thread1',
            'suggestion_type': feconf.SUGGESTION_TYPE_ADD_QUESTION,
            'target_type': feconf.ENTITY_TYPE_SKILL,
            'target_id': 'skill1',
            'target_version_at_submission': 1,
            'status': suggestion_models.STATUS_ACCEPTED,
            'author_name': 'author',
            'final_reviewer_id': self.reviewer_id,
            'change': {
                'cmd': question_domain.CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION,
                'question_dict': {
                    'question_state_data': question_state_dict,
                    'language_code': 'en',
                    'question_state_data_schema_version': (
                        feconf.CURRENT_STATE_SCHEMA_VERSION),
                    'linked_skill_ids': ['skill1'],
                    'inapplicable_skill_misconception_ids': []
                },
                'skill_id': 'skill1',
                'skill_difficulty': 0.3,
            },
            'score_category': 'question.skill1',
            'language_code': 'en',
            'last_updated': utils.get_time_in_millisecs(self.fake_date)
        }
        self.save_new_skill(
            'skill1', self.author_id, description='description')
        suggestion = suggestion_registry.SuggestionAddQuestion(
            suggestion_dict['suggestion_id'], suggestion_dict['target_id'],
            suggestion_dict['target_version_at_submission'],
            suggestion_dict['status'], self.author_id, self.reviewer_id,
            suggestion_dict['change'], suggestion_dict['score_category'],
            suggestion_dict['language_code'], False, self.fake_date)

        suggestion.accept('commit_message')

        question = question_services.get_questions_by_skill_ids(
            1, ['skill1'], False)[0]
        destination_fs = fs_domain.AbstractFileSystem(
            fs_domain.GcsFileSystem(
                feconf.ENTITY_TYPE_QUESTION, question.id))
        self.assertTrue(destination_fs.isfile('image/%s' % 'image.png'))
        self.assertEqual(
            suggestion.status,
            suggestion_models.STATUS_ACCEPTED)