def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) s = EntityRecognitionSkill(inputs=[ InputFieldMappingEntry(name="text", source="/document/content") ], outputs=[ OutputFieldMappingEntry( name="organizations", target_name="organizations") ]) ss = client.create_or_update_skillset(name='test-ss', skills=[s], description="desc1") etag = ss.e_tag client.create_or_update_skillset(name='test-ss', skills=[s], description="desc2", skillset=ss) assert len(client.get_skillsets()) == 1 ss.e_tag = etag with pytest.raises(HttpResponseError): client.create_or_update_skillset( name='test-ss', skills=[s], skillset=ss, match_condition=MatchConditions.IfNotModified)
def test_create_or_update_skillset_inplace(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) s = EntityRecognitionSkill(inputs=[ InputFieldMappingEntry(name="text", source="/document/content") ], outputs=[ OutputFieldMappingEntry( name="organizations", target_name="organizations") ]) ss = client.create_or_update_skillset(name='test-ss', skills=[s], description="desc1") client.create_or_update_skillset(name='test-ss', skills=[s], description="desc2", skillset=ss) assert len(client.get_skillsets()) == 1 result = client.get_skillset("test-ss") assert isinstance(result, SearchIndexerSkillset) assert result.name == "test-ss" assert result.description == "desc2"
def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) s = EntityRecognitionSkill(inputs=[ InputFieldMappingEntry(name="text", source="/document/content") ], outputs=[ OutputFieldMappingEntry( name="organizations", target_name="organizations") ]) skillset = SearchIndexerSkillset(name='test-ss', skills=list([s]), description="desc") result = client.create_skillset(skillset) etag = result.e_tag skillset = SearchIndexerSkillset(name='test-ss', skills=list([s]), description="updated") updated = client.create_or_update_skillset(skillset) updated.e_tag = etag with pytest.raises(HttpResponseError): client.delete_skillset( updated, match_condition=MatchConditions.IfNotModified)
def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) s = EntityRecognitionSkill(inputs=[ InputFieldMappingEntry(name="text", source="/document/content") ], outputs=[ OutputFieldMappingEntry( name="organizations", target_name="organizations") ]) skillset1 = SearchIndexerSkillset(name='test-ss', skills=list([s]), description="desc1") ss = client.create_or_update_skillset(skillset1) etag = ss.e_tag skillset2 = SearchIndexerSkillset(name='test-ss', skills=[s], description="desc2", skillset=ss) client.create_or_update_skillset(skillset2) assert len(client.get_skillsets()) == 1