How to use delete_health_check method in localstack

Best Python code snippet using localstack_python

test_health_check.py

Source:test_health_check.py Github

copy

Full Screen

...32 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], '54.217.7.118')33 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Port'], '80')34 self.assertEquals(result[u'CreateHealthCheckResponse'][35 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'], '/testing')36 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])37 def test_create_https_health_check(self):38 hc = HealthCheck(ip_addr="54.217.7.118", port=443, hc_type="HTTPS", resource_path="/testing")39 result = self.conn.create_health_check(hc)40 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Type'], 'HTTPS')41 self.assertEquals(result[u'CreateHealthCheckResponse'][42 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], '54.217.7.118')43 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Port'], '443')44 self.assertEquals(result[u'CreateHealthCheckResponse'][45 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'], '/testing')46 self.assertFalse('FullyQualifiedDomainName' in result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'])47 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])48 def test_create_https_health_check_fqdn(self):49 hc = HealthCheck(ip_addr=None, port=443, hc_type="HTTPS", resource_path="/", fqdn="google.com")50 result = self.conn.create_health_check(hc)51 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Type'], 'HTTPS')52 self.assertEquals(result[u'CreateHealthCheckResponse'][53 u'HealthCheck'][u'HealthCheckConfig'][u'FullyQualifiedDomainName'], 'google.com')54 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Port'], '443')55 self.assertEquals(result[u'CreateHealthCheckResponse'][56 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'], '/')57 self.assertFalse('IPAddress' in result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'])58 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])59 def test_create_and_list_health_check(self):60 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resource_path="/testing")61 result1 = self.conn.create_health_check(hc)62 hc = HealthCheck(ip_addr="54.217.7.119", port=80, hc_type="HTTP", resource_path="/testing")63 result2 = self.conn.create_health_check(hc)64 result = self.conn.get_list_health_checks()65 self.assertTrue(len(result['ListHealthChecksResponse']['HealthChecks']) > 1)66 self.conn.delete_health_check(result1['CreateHealthCheckResponse']['HealthCheck']['Id'])67 self.conn.delete_health_check(result2['CreateHealthCheckResponse']['HealthCheck']['Id'])68 def test_delete_health_check(self):69 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resource_path="/testing")70 result = self.conn.create_health_check(hc)71 hc_id = result['CreateHealthCheckResponse']['HealthCheck']['Id']72 result = self.conn.get_list_health_checks()73 found = False74 for hc in result['ListHealthChecksResponse']['HealthChecks']:75 if hc['Id'] == hc_id:76 found = True77 break78 self.assertTrue(found)79 result = self.conn.delete_health_check(hc_id)80 result = self.conn.get_list_health_checks()81 for hc in result['ListHealthChecksResponse']['HealthChecks']:82 self.assertFalse(hc['Id'] == hc_id)83 def test_create_health_check_string_match(self):84 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP_STR_MATCH", resource_path="/testing", string_match="test")85 result = self.conn.create_health_check(hc)86 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Type'], 'HTTP_STR_MATCH')87 self.assertEquals(result[u'CreateHealthCheckResponse'][88 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], '54.217.7.118')89 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Port'], '80')90 self.assertEquals(result[u'CreateHealthCheckResponse'][91 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'], '/testing')92 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'SearchString'], 'test')93 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])94 def test_create_health_check_https_string_match(self):95 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTPS_STR_MATCH", resource_path="/testing", string_match="test")96 result = self.conn.create_health_check(hc)97 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Type'], 'HTTPS_STR_MATCH')98 self.assertEquals(result[u'CreateHealthCheckResponse'][99 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], '54.217.7.118')100 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'Port'], '80')101 self.assertEquals(result[u'CreateHealthCheckResponse'][102 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'], '/testing')103 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u'HealthCheckConfig'][u'SearchString'], 'test')104 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])105 def test_create_resource_record_set(self):106 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resource_path="/testing")107 result = self.conn.create_health_check(hc)108 records = ResourceRecordSets(109 connection=self.conn, hosted_zone_id=self.zone.id, comment='Create DNS entry for test')110 change = records.add_change('CREATE', 'unittest.%s.' % self.base_domain, 'A', ttl=30, identifier='test',111 weight=1, health_check=result['CreateHealthCheckResponse']['HealthCheck']['Id'])112 change.add_value("54.217.7.118")113 records.commit()114 records = ResourceRecordSets(self.conn, self.zone.id)115 deleted = records.add_change('DELETE', "unittest.%s." % self.base_domain, "A", ttl=30, identifier='test',116 weight=1, health_check=result['CreateHealthCheckResponse']['HealthCheck']['Id'])117 deleted.add_value('54.217.7.118')118 records.commit()119 def test_create_health_check_invalid_request_interval(self):120 """Test that health checks cannot be created with an invalid121 'request_interval'.122 """123 self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(request_interval=5)))124 def test_create_health_check_invalid_failure_threshold(self):125 """126 Test that health checks cannot be created with an invalid127 'failure_threshold'.128 """129 self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(failure_threshold=0)))130 self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(failure_threshold=11)))131 def test_create_health_check_request_interval(self):132 hc_params = self.health_check_params(request_interval=10)133 hc = HealthCheck(**hc_params)134 result = self.conn.create_health_check(hc)135 hc_config = (result[u'CreateHealthCheckResponse']136 [u'HealthCheck'][u'HealthCheckConfig'])137 self.assertEquals(hc_config[u'RequestInterval'],138 six.text_type(hc_params['request_interval']))139 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])140 def test_create_health_check_failure_threshold(self):141 hc_params = self.health_check_params(failure_threshold=1)142 hc = HealthCheck(**hc_params)143 result = self.conn.create_health_check(hc)144 hc_config = (result[u'CreateHealthCheckResponse']145 [u'HealthCheck'][u'HealthCheckConfig'])146 self.assertEquals(hc_config[u'FailureThreshold'],147 six.text_type(hc_params['failure_threshold']))148 self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])149 def health_check_params(self, **kwargs):150 params = {151 'ip_addr': "54.217.7.118",152 'port': 80,153 'hc_type': 'HTTP',154 'resource_path': '/testing',155 }156 params.update(kwargs)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful