Exemplo n.º 1
0
    def test_dict_access(self):
        response = {
            'foo': 'bar',
        }

        response_object = IndexingResponse({}, [response])
        self.assertEqual(response_object[0]['foo'], 'bar')

        response_object = MultipleResponse([response])
        self.assertEqual(response_object[0]['foo'], 'bar')

        response_object = MultipleResponse([IndexingResponse({}, [response])])
        self.assertEqual(response_object[0][0]['foo'], 'bar')

        response_object = AddApiKeyResponse({}, response)
        self.assertEqual(response_object['foo'], 'bar')

        response_object = UpdateApiKeyResponse({}, response, {})
        self.assertEqual(response_object['foo'], 'bar')

        response_object = DeleteApiKeyResponse({}, response, '')
        self.assertEqual(response_object['foo'], 'bar')

        response_object = MultipleIndexBatchIndexingResponse({}, response)
        self.assertEqual(response_object['foo'], 'bar')
    def add_api_key(self, acl, request_options=None):
        # type: (list, Optional[Union[dict, RequestOptions]]) -> AddApiKeyResponse # noqa: E501

        raw_response = self._transporter.write(Verb.POST, "1/keys",
                                               {"acl": acl}, request_options)

        return AddApiKeyResponse(self, raw_response)
    def test_dict_access(self):
        response = {
            "foo": "bar",
        }

        response_object = IndexingResponse({}, [response])
        self.assertEqual(response_object[0]["foo"], "bar")

        response_object = MultipleResponse([response])
        self.assertEqual(response_object[0]["foo"], "bar")

        response_object = MultipleResponse([IndexingResponse({}, [response])])
        self.assertEqual(response_object[0][0]["foo"], "bar")

        response_object = AddApiKeyResponse({}, response)
        self.assertEqual(response_object["foo"], "bar")

        response_object = UpdateApiKeyResponse({}, response, {})
        self.assertEqual(response_object["foo"], "bar")

        response_object = DeleteApiKeyResponse({}, response, "")
        self.assertEqual(response_object["foo"], "bar")

        response_object = MultipleIndexBatchIndexingResponse({}, response)
        self.assertEqual(response_object["foo"], "bar")