'Checks that handler to save tags in StructuredTagsAside works properly'

@ddt.data(AsideUsageKeyV1, AsideUsageKeyV2)
def test_handle_requests(self, aside_key_class):

    handler_url = reverse_usage_url('component_handler', unicode(aside_key_class(self.problem.location, self.aside_name)), kwargs={'handler': 'save_tags'})
    client = AjaxEnabledTestClient()
    client.login(username=self.user.username, password=self.user_password)
    response = client.post(handler_url, json.dumps({}), content_type='application/json')
    self.assertEqual(response.status_code, 400)
    response = client.post(handler_url, json.dumps({'undefined_tag': ['undefined1', 'undefined2']}), content_type='application/json')
    self.assertEqual(response.status_code, 400)
    response = client.post(handler_url, json.dumps({self.aside_tag_dif: ['undefined1', 'undefined2']}), content_type='application/json')
    self.assertEqual(response.status_code, 400)
    def _test_helper_func(problem_location):
        '\n                                                Helper    function\n                                                '
        problem = modulestore().get_item(problem_location)
        asides = problem.runtime.get_asides(problem)
        tag_aside = None
        for aside in asides:
            if isinstance(aside, StructuredTagsAside):
                tag_aside = aside
                break
        return tag_aside
    response = client.post(handler_url, json.dumps({self.aside_tag_dif: [self.aside_tag_dif_value]}), content_type='application/json')
    self.assertEqual(response.status_code, 200)
    tag_aside = _test_helper_func(self.problem.location)
    self.assertIsNotNone(tag_aside, "Necessary    StructuredTagsAside    object    isn't    found")
    self.assertEqual(tag_aside.saved_tags[self.aside_tag_dif], [self.aside_tag_dif_value])
    response = client.post(handler_url, json.dumps({self.aside_tag_dif: [self.aside_tag_dif_value, self.aside_tag_dif_value2]}), content_type='application/json')
    self.assertEqual(response.status_code, 200)
    tag_aside = _test_helper_func(self.problem.location)
    self.assertIsNotNone(tag_aside, "Necessary    StructuredTagsAside    object    isn't    found")
    self.assertEqual(tag_aside.saved_tags[self.aside_tag_dif], [self.aside_tag_dif_value, self.aside_tag_dif_value2])
