Best Python code snippet using localstack_python
test_boto3_elasticsearch.py
Source:test_boto3_elasticsearch.py
...790 with patch.object(791 self.conn, "get_compatible_elasticsearch_versions", return_value=ret_val792 ):793 self.assertEqual(794 boto3_elasticsearch.get_compatible_elasticsearch_versions(795 domain_name="testdomain", **CONN_PARAMETERS796 ),797 {798 "result": True,799 "response": ret_val["CompatibleElasticsearchVersions"],800 },801 )802 def test_get_compatible_elasticsearch_versions_error(self):803 """804 Test that when calling get_compatible_elasticsearch_versions and boto3805 returns an error, it returns {'result': False, 'error': 'the error'}.806 """807 with patch.object(808 self.conn,809 "get_compatible_elasticsearch_versions",810 side_effect=ClientError(811 ERROR_CONTENT, "get_compatible_elasticsearch_versions"812 ),813 ):814 result = boto3_elasticsearch.get_compatible_elasticsearch_versions(815 domain_name="testdomain", **CONN_PARAMETERS816 )817 self.assertFalse(result["result"])818 self.assertEqual(819 result.get("error", ""),820 ERROR_MESSAGE.format(101, "get_compatible_elasticsearch_versions"),821 )822 def test_get_upgrade_history_positive(self):823 """824 Test that when calling get_upgrade_history and it825 succeeds, it returns {'result': True, 'response': some_value}.826 """827 ret_val = {828 "UpgradeHistories": [...
test_es.py
Source:test_es.py
...56 assert "OpenSearch_1.0" in versions57 assert "OpenSearch_1.1" in versions58 assert "7.10" in versions59 def test_get_compatible_versions(self, es_client):60 response = es_client.get_compatible_elasticsearch_versions()61 assert "CompatibleElasticsearchVersions" in response62 versions = response["CompatibleElasticsearchVersions"]63 assert len(versions) == 1864 assert {"SourceVersion": "OpenSearch_1.0", "TargetVersions": ["OpenSearch_1.1"]} in versions65 assert {66 "SourceVersion": "7.10",67 "TargetVersions": ["OpenSearch_1.0", "OpenSearch_1.1"],68 } in versions69 assert {70 "SourceVersion": "7.7",71 "TargetVersions": ["7.8", "7.9", "7.10", "OpenSearch_1.0", "OpenSearch_1.1"],72 } in versions73 def test_get_compatible_version_for_domain(self, es_client, opensearch_domain):74 response = es_client.get_compatible_elasticsearch_versions(DomainName=opensearch_domain)75 assert "CompatibleElasticsearchVersions" in response76 versions = response["CompatibleElasticsearchVersions"]77 # The default version is the latest version, which is not compatible with any previous versions78 assert len(versions) == 079 def test_create_domain(self, es_client, opensearch_create_domain):80 es_domain = opensearch_create_domain(EngineVersion=ELASTICSEARCH_DEFAULT_VERSION)81 response = es_client.list_domain_names(EngineType="Elasticsearch")82 domain_names = [domain["DomainName"] for domain in response["DomainNames"]]83 assert es_domain in domain_names84 def test_create_existing_domain_causes_exception(self, es_client, opensearch_create_domain):85 domain_name = opensearch_create_domain(EngineVersion=ELASTICSEARCH_DEFAULT_VERSION)86 with pytest.raises(botocore.exceptions.ClientError) as exc_info:87 es_client.create_elasticsearch_domain(DomainName=domain_name)88 assert exc_info.type.__name__ == "ResourceAlreadyExistsException"...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!