|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
3 | 3 | """ |
4 | | -Copyright (c) 2014-2019 Basis Technology Corporation. |
| 4 | +Copyright (c) 2014-2022 Basis Technology Corporation. |
5 | 5 |
|
6 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | you may not use this file except in compliance with the License. |
@@ -202,6 +202,8 @@ def test_the_max_pool_size(json_response, doc_params): |
202 | 202 | result = api.language(doc_params) |
203 | 203 | assert result["name"] == "Rosette" |
204 | 204 | assert api.get_pool_size() == 5 |
| 205 | + api.set_pool_size(11) |
| 206 | + assert api.get_pool_size() == 11 |
205 | 207 | httpretty.disable() |
206 | 208 | httpretty.reset() |
207 | 209 |
|
@@ -756,3 +758,57 @@ def test_the_similar_terms_endpoint(api, json_response, doc_params): |
756 | 758 | assert result["name"] == "Rosette" |
757 | 759 | httpretty.disable() |
758 | 760 | httpretty.reset() |
| 761 | + |
| 762 | + |
| 763 | +def test_the_deprecated_endpoints(api, json_response, doc_params): |
| 764 | + """There are three deprecated endpoints. Exercise them until they are deleted.""" |
| 765 | + |
| 766 | + # TEXT_EMBEDDING calls SEMANTIC_VECTORS |
| 767 | + httpretty.enable() |
| 768 | + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/semantics/vector", |
| 769 | + body=json_response, status=200, content_type="application/json") |
| 770 | + |
| 771 | + result = api.text_embedding(doc_params) |
| 772 | + assert result["name"] == "Rosette" |
| 773 | + httpretty.disable() |
| 774 | + httpretty.reset() |
| 775 | + |
| 776 | + # MATCHED_NAME calls NAME_SIMILARITY |
| 777 | + httpretty.enable() |
| 778 | + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", |
| 779 | + body=json_response, status=200, content_type="application/json") |
| 780 | + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-similarity", |
| 781 | + body=json_response, status=200, content_type="application/json") |
| 782 | + |
| 783 | + name_similarity_params = NameSimilarityParameters() |
| 784 | + |
| 785 | + name_similarity_params["name1"] = { |
| 786 | + "text": "Michael Jackson", |
| 787 | + "language": "eng", |
| 788 | + "entityType": "PERSON"} |
| 789 | + |
| 790 | + name_similarity_params["name2"] = {"text": "迈克尔·杰克逊", "entityType": "PERSON"} |
| 791 | + |
| 792 | + result = api.matched_name(name_similarity_params) |
| 793 | + assert result["name"] == "Rosette" |
| 794 | + httpretty.disable() |
| 795 | + httpretty.reset() |
| 796 | + |
| 797 | + # TRANSLATED_NAME calls NAME_TRANSLATION |
| 798 | + httpretty.enable() |
| 799 | + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info", |
| 800 | + body=json_response, status=200, content_type="application/json") |
| 801 | + httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/name-translation", |
| 802 | + body=json_response, status=200, content_type="application/json") |
| 803 | + |
| 804 | + name_translation_params = NameTranslationParameters() |
| 805 | + name_translation_params["entityType"] = "PERSON" |
| 806 | + name_translation_params["targetScript"] = "Latn" |
| 807 | + name_translation_params["name"] = "some data to translate" |
| 808 | + name_translation_params["targetLanguage"] = "eng" |
| 809 | + |
| 810 | + result = api.translated_name(name_translation_params) |
| 811 | + assert result["name"] == "Rosette" |
| 812 | + |
| 813 | + httpretty.disable() |
| 814 | + httpretty.reset() |
0 commit comments