from expertai.nlapi.cloud.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."
language = 'en'

output = client.contexts()

# Contexts

print("Contexts:")

for context in output.contexts:
    print(context.name)
    print("\tLanguages:")
    for language in context.languages:
        print("\t", language.code)
    def test_a_context_request_is_executed(self):
        """
        ...then verify that whole flow works as expected
        """
        response_json = {
            "success":
            True,
            "contexts": [{
                "description":
                "Standard context",
                "languages": [{
                    "analyses": [
                        "disambiguation", "relevants", "entities", "sentiment",
                        "relations"
                    ],
                    "code":
                    "en",
                    "name":
                    "English"
                }, {
                    "analyses":
                    ["disambiguation", "relevants", "entities", "relations"],
                    "code":
                    "es",
                    "name":
                    "Spanish"
                }, {
                    "analyses":
                    ["disambiguation", "relevants", "entities", "relations"],
                    "code":
                    "fr",
                    "name":
                    "French"
                }, {
                    "analyses":
                    ["disambiguation", "relevants", "entities", "relations"],
                    "code":
                    "de",
                    "name":
                    "German"
                }, {
                    "analyses":
                    ["disambiguation", "relevants", "entities", "relations"],
                    "code":
                    "it",
                    "name":
                    "Italian"
                }],
                "name":
                "standard"
            }]
        }
        response = MagicMock()
        response.status_code = 200
        response.ok = True
        response.json.return_value = response_json

        self.patched_get.return_value = response
        client = ExpertAiClient()
        dm = client.contexts()
        self.assertEqual(dm.contexts[0].name, "standard")
        self.assertEqual(dm.contexts[0].languages[4].code, "it")
        self.assertEqual(dm.contexts[0].languages[3].analyses[2], "entities")