How to use delete_variable method in autotest

Best Python code snippet using autotest_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...22 def delete(call):23 data = call.data24 entity_id = data[CONF_ENTITY_ID]25 saver_entity.delete(entity_id)26 def delete_variable(call):27 data = call.data28 variable = data[CONF_NAME]29 saver_entity.delete_variable(variable)30 def execute(call):31 data = call.data32 script = data[CONF_SCRIPT]33 saver_entity.execute(script)34 def restore_state(call):35 data = call.data36 entity_id = data[CONF_ENTITY_ID]37 restore_script = data[CONF_RESTORE_SCRIPT]38 should_delete = data[CONF_DELETE_AFTER_RUN]39 saver_entity.restore(entity_id, restore_script, should_delete)40 def save_state(call):41 data = call.data42 entity_id = data[CONF_ENTITY_ID]43 saver_entity.save(entity_id)44 def set_variable(call):45 data = call.data46 name = data[CONF_NAME]47 value = data[CONF_VALUE]48 saver_entity.set_variable(name, value)49 hass.services.register(DOMAIN, SERVICE_CLEAR, clear, SERVICE_CLEAR_SCHEMA)50 hass.services.register(DOMAIN, SERVICE_DELETE, delete, SERVICE_DELETE_SCHEMA)51 hass.services.register(DOMAIN, SERVICE_DELETE_VARIABLE, delete_variable, SERVICE_DELETE_VARIABLE_SCHEMA)52 hass.services.register(DOMAIN, SERVICE_EXECUTE, execute, SERVICE_EXECUTE_SCHEMA)53 hass.services.register(DOMAIN, SERVICE_RESTORE_STATE, restore_state, SERVICE_RESTORE_STATE_SCHEMA)54 hass.services.register(DOMAIN, SERVICE_SAVE_STATE, save_state, SERVICE_SAVE_STATE_SCHEMA)55 hass.services.register(DOMAIN, SERVICE_SET_VARIABLE, set_variable, SERVICE_SET_VARIABLE_SCHEMA)56 return True57class SaverEntity(RestoreEntity):58 def __init__(self):59 self._entities_db = {}60 self._variables_db = {}61 @property62 def name(self):63 return DOMAIN64 def clear(self):65 self._entities_db.clear()66 self._variables_db.clear()67 self.schedule_update_ha_state()68 def delete(self, entity_id):69 self._entities_db.pop(entity_id)70 self.schedule_update_ha_state()71 def delete_variable(self, variable):72 self._variables_db.pop(variable)73 self.schedule_update_ha_state()74 def execute(self, script):75 script = Script(self.hass, script, self.name, DOMAIN, script_mode=SCRIPT_MODE_PARALLEL)76 variables = {}77 variables.update(self._variables_db)78 for entity_id in self._entities_db:79 variables.update(SaverEntity.convert_to_variables(self._entities_db[entity_id], entity_id))80 script.run(variables=variables, context=Context())81 self.schedule_update_ha_state()82 def restore(self, entity_id, restore_script, delete):83 if entity_id not in self._entities_db:84 return85 old = self._entities_db[entity_id]...

Full Screen

Full Screen

variables.py

Source:variables.py Github

copy

Full Screen

...18 fraudDetector.create_variable(name = 'order_price',variableType = 'PRICE',dataSource = 'EVENT',dataType = 'FLOAT',defaultValue = '0.0')19 fraudDetector.create_variable(name = 'payment_currency',variableType = 'CURRENCY_CODE',dataSource = 'EVENT',dataType = 'STRING',defaultValue = 'null')20 fraudDetector.create_variable(name = 'merchant',variableType = 'CATEGORICAL',dataSource = 'EVENT',dataType = 'STRING',defaultValue = 'null')21def delete_variables():22 fraudDetector.delete_variable(name = 'card_bin')23 fraudDetector.delete_variable(name = 'customer_name')24 fraudDetector.delete_variable(name = 'billing_street')25 fraudDetector.delete_variable(name = 'billing_city')26 fraudDetector.delete_variable(name = 'billing_state')27 fraudDetector.delete_variable(name = 'billing_zip')28 fraudDetector.delete_variable(name = 'billing_latitude')29 fraudDetector.delete_variable(name = 'billing_longitude')30 fraudDetector.delete_variable(name = 'customer_job')31 fraudDetector.delete_variable(name = 'ip_address')32 fraudDetector.delete_variable(name = 'customer_email')33 fraudDetector.delete_variable(name = 'phone')34 fraudDetector.delete_variable(name = 'user_agent')35 fraudDetector.delete_variable(name = 'product_category')36 fraudDetector.delete_variable(name = 'order_price')37 fraudDetector.delete_variable(name = 'payment_currency')...

Full Screen

Full Screen

test_utility.py

Source:test_utility.py Github

copy

Full Screen

...26 in_fnames = read_fnames("test_data/filenames.txt")27 true_fnames = ["test1", "test2", "filename3.txt", "ncfile.nc"]28 for in_fname, true_fname in zip(in_fnames, true_fnames):29 assert in_fname == true_fname30def test_delete_variable():31 fname = "./test_data/contains_extra_var.nc"32 ds = xr.load_dataset(fname)33 # Ensure ds initially contains the variable34 assert "crs" in ds35 # Ensure deleting works36 delete_variable(ds, "crs")37 assert "crs" not in ds38 # Ensure deleting a missing variable throws39 with pytest.raises(ValueError, match=f"Could not find crs in dataset"):...

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 autotest 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