How to use _has_status method in localstack

Best Python code snippet using localstack_python

asserts.py

Source:asserts.py Github

copy

Full Screen

...509 >>> import requests510 >>> res = requests.get("https://google.com")511 >>> assert_that(res).has_status_ok()512 """513 return self._has_status(200)514 def has_status_created(self):515 """Assert that the response has HTTP status code 201 (Created)."""516 return self._has_status(201)517 def has_status_accepted(self):518 """Assert that the response has HTTP status code 202 (Accepted)."""519 return self._has_status(202)520 def has_status_no_content(self):521 """Assert that the response has HTTP status code 204 (No content)."""522 return self._has_status(204)523 def has_status_bad_request(self):524 """Assert that the response has HTTP status code 400 (Bad request)."""525 return self._has_status(400)526 def has_status_unauthorized(self):527 """Assert that the response has HTTP status code 401 (Unauthorized)."""528 return self._has_status(401)529 def has_status_forbidden(self):530 """Assert that the response has HTTP status code 403 (Forbidden)."""531 return self._has_status(403)532 def has_status_not_found(self):533 """Assert that the response has HTTP status code 404 (Not found)."""534 return self._has_status(404)535 def has_status_method_not_allowed(self):536 """Assert that the response has HTTP status code 405 (Method not allowed)."""537 return self._has_status(405)538 def has_status_conflict(self):539 """Assert that the response has HTTP status code 409 (Conflict)."""540 return self._has_status(409)541 def has_status_precondition_failed(self):542 """Assert that the response has HTTP status code 412 (Precondition failed)."""543 return self._has_status(412)544 def has_status_internal_server_error(self):545 """Assert that the response has HTTP status code 412 (Internal server error)."""546 return self._has_status(500)547 def has_status_service_unavailable(self):548 """Assert that the response has HTTP status code 503 (Service unavailable)."""549 return self._has_status(503)550 def has_status_gateway_timeout(self):551 """Assert that the response has HTTP status code 504 (Gateway timeout)."""552 return self._has_status(504)553 def _has_status(self, expected: int):554 for attr in ["status_code", "status", "statuscode"]:555 status = getattr(self.value, attr, 0)556 if status != 0:557 break558 if status == 0:559 raise TypeError("{} does not have any status code attribute")560 msg = "Expected HTTP status {} but was {}".format(expected, self.value.status_code)561 assert_equal(status, expected, msg)562 def body_length(self, length: int):563 """Assert that the response body has the given length. 564 Args:565 length (int): the expected length of the body566 """567 msg = "Expected body {} to have length {}".format(self.value.json(), length)...

Full Screen

Full Screen

shared_status.py

Source:shared_status.py Github

copy

Full Screen

...53 def mark_submodule_status(self, submodule_name, status):54 self.status[_FieldsNames.LAST_UPDATE] = _int_seconds_from_epoch()55 self.submodules_status[submodule_name] = status56 def as_dict(self):57 crit_submod = self._has_status(_StatusHandler.CRIT_STATUS)58 warn_submod = self._has_status(_StatusHandler.WARN_STATUS)59 status = _StatusHandler.OK_STATUS60 desc = SharedStatus.HEALTHY_BANNER61 if crit_submod:62 status = _StatusHandler.CRIT_STATUS63 desc = 'critical errors in ' + ' '.join(crit_submod)64 elif warn_submod:65 status = _StatusHandler.WARN_STATUS66 desc = 'warnings in ' + ' '.join(warn_submod)67 self.status[_FieldsNames.STATUS] = status68 self.status[_FieldsNames.DESC] = desc69 extendend_status = {70 submodule_name: status._asdict()71 for submodule_name, status in self.submodules_status.iteritems()72 }73 return dict(74 self.status, **{_FieldsNames.EXTENDEND_STATUS: extendend_status})75 def _has_status(self, status):76 return [77 module78 for module, st in self.submodules_status.iteritems()79 if st.status == status...

Full Screen

Full Screen

check.py

Source:check.py Github

copy

Full Screen

1"""2Module contains custom extensions for assertpy lib3"""4from assertpy.assertpy import AssertionBuilder, add_extension, assert_that, soft_assertions5def _has_status(self: AssertionBuilder, status: str) -> AssertionBuilder:6 actual_status = self.val.get('status')7 if actual_status != status:8 self.error(9 f'Invalid status for \'{self.val.get("method")}\'. Expected <{status}>, but was <{actual_status}>'10 )11 return self12def is_success(self: AssertionBuilder) -> AssertionBuilder:13 return _has_status(self, 'success')14def is_failure(self: AssertionBuilder) -> AssertionBuilder:15 return _has_status(self, 'failure')16add_extension(is_success)17add_extension(is_failure)18softly = soft_assertions...

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