Best Python code snippet using tempest_python
test_alerts.py
Source:test_alerts.py
...70 def test_when_service_is_gone_task_is_skipped(self, mock_backend):71 service = self.create_service()72 service_str = service.to_string()73 service.delete()74 tasks.check_service_availability(service_str)75 self.assertFalse(mock_backend.called)76 tasks.check_service_availability(service_str)77 self.assertFalse(mock_backend.called)78 tasks.check_service_resources_availability(service_str)79 self.assertFalse(mock_backend.called)80 def test_when_service_is_unavailable_alert_is_created(self, mock_backend):81 service = self.create_service()82 mock_backend().ping.return_value = False83 tasks.check_service_availability(service.to_string())84 self.assertTrue(mock_backend.called)85 self.assertTrue(self.has_alert(service, 'service_unavailable'))86 def test_when_erred_service_responds_to_ping_it_is_recovered(self, mock_backend):87 service = self.create_service()88 service.settings.set_erred()89 service.settings.save()90 mock_backend().ping.return_value = True91 tasks.check_service_availability(service.to_string())92 self.assertFalse(self.has_alert(service, 'service_unavailable'))93 service.refresh_from_db()94 self.assertTrue(ServiceSettings.States.OK, service.settings.state)95@mock.patch('nodeconductor_plus.insights.tasks.alert_logger')96class CustomerCostsTest(BaseAlertTest, test.APITransactionTestCase):97 def test_when_cost_exceeded_alert_created(self, mocked_event_logger):98 customer = factories.CustomerFactory()99 self.create_price_estimates(customer, 10, 100)100 check_customer_costs(customer.uuid.hex)101 mocked_event_logger.customer_state.warning.assert_called_once_with(102 'This month estimated costs for customer {customer_name} exceeded',103 scope=customer,104 alert_type='customer_projected_costs_exceeded',105 alert_context={'customer': customer}...
__init__.py
Source:__init__.py
...65 reason = "Environment variable {} is unset".format(ex.args[0])66 raise SecretServiceNotAvailableException(reason) from ex67 except (ConnectionError, ValueError) as ex:68 raise SecretServiceNotAvailableException(str(ex)) from ex69def check_service_availability(connection: DBusConnection) -> bool:70 """Returns True if the Secret Service daemon is either running or71 available for activation via D-Bus, False otherwise.72 .. versionadded:: 3.273 """74 from secretstorage.util import BUS_NAME75 proxy = Proxy(message_bus, connection)76 return (proxy.NameHasOwner(BUS_NAME)[0] == 1...
test_context_manager.py
Source:test_context_manager.py
...11 """``dbus_init()`` should work fine with ``contextlib.closing``12 context manager."""13 def test_closing_context_manager(self) -> None:14 with closing(dbus_init()) as connection:15 self.assertTrue(check_service_availability(connection))16 collection = get_any_collection(connection)17 self.assertIsNotNone(collection)18 label = collection.get_label()...
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!!