Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
UsgsEarthquakesEvent.async_update
(self)
Update this entity from the data held in the feed manager.
Update this entity from the data held in the feed manager.
async def async_update(self): """Update this entity from the data held in the feed manager.""" _LOGGER.debug("Updating %s", self._external_id) feed_entry = self._feed_manager.get_entry(self._external_id) if feed_entry: self._update_from_feed(feed_entry)
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating %s\"", ",", "self", ".", "_external_id", ")", "feed_entry", "=", "self", ".", "_feed_manager", ".", "get_entry", "(", "self", ".", "_external_id", ")", "if", "...
[ 225, 4 ]
[ 230, 46 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent._update_from_feed
(self, feed_entry)
Update the internal state from the provided feed entry.
Update the internal state from the provided feed entry.
def _update_from_feed(self, feed_entry): """Update the internal state from the provided feed entry.""" self._name = feed_entry.title self._distance = feed_entry.distance_to_home self._latitude = feed_entry.coordinates[0] self._longitude = feed_entry.coordinates[1] self._a...
[ "def", "_update_from_feed", "(", "self", ",", "feed_entry", ")", ":", "self", ".", "_name", "=", "feed_entry", ".", "title", "self", ".", "_distance", "=", "feed_entry", ".", "distance_to_home", "self", ".", "_latitude", "=", "feed_entry", ".", "coordinates", ...
[ 232, 4 ]
[ 245, 38 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" return "mdi:pulse"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:pulse\"" ]
[ 248, 4 ]
[ 250, 26 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.source
(self)
Return source value of this external event.
Return source value of this external event.
def source(self) -> str: """Return source value of this external event.""" return SOURCE
[ "def", "source", "(", "self", ")", "->", "str", ":", "return", "SOURCE" ]
[ 253, 4 ]
[ 255, 21 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str | None: """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_name" ]
[ 258, 4 ]
[ 260, 25 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.distance
(self)
Return distance value of this external event.
Return distance value of this external event.
def distance(self) -> float | None: """Return distance value of this external event.""" return self._distance
[ "def", "distance", "(", "self", ")", "->", "float", "|", "None", ":", "return", "self", ".", "_distance" ]
[ 263, 4 ]
[ 265, 29 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.latitude
(self)
Return latitude value of this external event.
Return latitude value of this external event.
def latitude(self) -> float | None: """Return latitude value of this external event.""" return self._latitude
[ "def", "latitude", "(", "self", ")", "->", "float", "|", "None", ":", "return", "self", ".", "_latitude" ]
[ 268, 4 ]
[ 270, 29 ]
python
en
['en', 'la', 'en']
True
UsgsEarthquakesEvent.longitude
(self)
Return longitude value of this external event.
Return longitude value of this external event.
def longitude(self) -> float | None: """Return longitude value of this external event.""" return self._longitude
[ "def", "longitude", "(", "self", ")", "->", "float", "|", "None", ":", "return", "self", ".", "_longitude" ]
[ 273, 4 ]
[ 275, 30 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return DEFAULT_UNIT_OF_MEASUREMENT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "DEFAULT_UNIT_OF_MEASUREMENT" ]
[ 278, 4 ]
[ 280, 42 ]
python
en
['en', 'la', 'en']
True
UsgsEarthquakesEvent.extra_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def extra_state_attributes(self): """Return the device state attributes.""" attributes = {} for key, value in ( (ATTR_EXTERNAL_ID, self._external_id), (ATTR_PLACE, self._place), (ATTR_MAGNITUDE, self._magnitude), (ATTR_TIME, self._time), ...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "for", "key", ",", "value", "in", "(", "(", "ATTR_EXTERNAL_ID", ",", "self", ".", "_external_id", ")", ",", "(", "ATTR_PLACE", ",", "self", ".", "_place", ")", ",", "(...
[ 283, 4 ]
[ 299, 25 ]
python
en
['en', 'en', 'en']
True
_basic_auth_str
(username, password)
Returns a Basic Auth string.
Returns a Basic Auth string.
def _basic_auth_str(username, password): """Returns a Basic Auth string.""" # "I want us to put a big-ol' comment on top of it that # says that this behaviour is dumb but we need to preserve # it because people are relying on it." # - Lukasa # # These are here solely to maintain backward...
[ "def", "_basic_auth_str", "(", "username", ",", "password", ")", ":", "# \"I want us to put a big-ol' comment on top of it that", "# says that this behaviour is dumb but we need to preserve", "# it because people are relying on it.\"", "# - Lukasa", "#", "# These are here solely to main...
[ 27, 0 ]
[ 68, 18 ]
python
en
['en', 'en', 'en']
True
HTTPDigestAuth.build_digest_header
(self, method, url)
:rtype: str
:rtype: str
def build_digest_header(self, method, url): """ :rtype: str """ realm = self._thread_local.chal['realm'] nonce = self._thread_local.chal['nonce'] qop = self._thread_local.chal.get('qop') algorithm = self._thread_local.chal.get('algorithm') opaque = self._...
[ "def", "build_digest_header", "(", "self", ",", "method", ",", "url", ")", ":", "realm", "=", "self", ".", "_thread_local", ".", "chal", "[", "'realm'", "]", "nonce", "=", "self", ".", "_thread_local", ".", "chal", "[", "'nonce'", "]", "qop", "=", "sel...
[ 126, 4 ]
[ 226, 35 ]
python
en
['en', 'error', 'th']
False
HTTPDigestAuth.handle_redirect
(self, r, **kwargs)
Reset num_401_calls counter on redirects.
Reset num_401_calls counter on redirects.
def handle_redirect(self, r, **kwargs): """Reset num_401_calls counter on redirects.""" if r.is_redirect: self._thread_local.num_401_calls = 1
[ "def", "handle_redirect", "(", "self", ",", "r", ",", "*", "*", "kwargs", ")", ":", "if", "r", ".", "is_redirect", ":", "self", ".", "_thread_local", ".", "num_401_calls", "=", "1" ]
[ 228, 4 ]
[ 231, 48 ]
python
en
['en', 'en', 'en']
True
HTTPDigestAuth.handle_401
(self, r, **kwargs)
Takes the given response and tries digest-auth, if needed. :rtype: requests.Response
Takes the given response and tries digest-auth, if needed.
def handle_401(self, r, **kwargs): """ Takes the given response and tries digest-auth, if needed. :rtype: requests.Response """ # If response is not 4xx, do not auth # See https://github.com/psf/requests/issues/3772 if not 400 <= r.status_code < 500: ...
[ "def", "handle_401", "(", "self", ",", "r", ",", "*", "*", "kwargs", ")", ":", "# If response is not 4xx, do not auth", "# See https://github.com/psf/requests/issues/3772", "if", "not", "400", "<=", "r", ".", "status_code", "<", "500", ":", "self", ".", "_thread_l...
[ 233, 4 ]
[ 275, 16 ]
python
en
['en', 'error', 'th']
False
OAuth2FlowHandler.logger
(self)
Return logger.
Return logger.
def logger(self) -> logging.Logger: """Return logger.""" return logging.getLogger(__name__)
[ "def", "logger", "(", "self", ")", "->", "logging", ".", "Logger", ":", "return", "logging", ".", "getLogger", "(", "__name__", ")" ]
[ 16, 4 ]
[ 18, 42 ]
python
en
['es', 'no', 'en']
False
OAuth2FlowHandler.extra_authorize_data
(self)
Extra data that needs to be appended to the authorize url.
Extra data that needs to be appended to the authorize url.
def extra_authorize_data(self) -> dict: """Extra data that needs to be appended to the authorize url.""" scopes = ["Xboxlive.signin", "Xboxlive.offline_access"] return {"scope": " ".join(scopes)}
[ "def", "extra_authorize_data", "(", "self", ")", "->", "dict", ":", "scopes", "=", "[", "\"Xboxlive.signin\"", ",", "\"Xboxlive.offline_access\"", "]", "return", "{", "\"scope\"", ":", "\" \"", ".", "join", "(", "scopes", ")", "}" ]
[ 21, 4 ]
[ 24, 42 ]
python
en
['en', 'en', 'en']
True
OAuth2FlowHandler.async_step_user
(self, user_input=None)
Handle a flow start.
Handle a flow start.
async def async_step_user(self, user_input=None): """Handle a flow start.""" await self.async_set_unique_id(DOMAIN) if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") return await super().async_step_user(user_input)
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "await", "self", ".", "async_set_unique_id", "(", "DOMAIN", ")", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", ...
[ 26, 4 ]
[ 33, 56 ]
python
en
['en', 'lb', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up TotalConnect device sensors based on a config entry.
Set up TotalConnect device sensors based on a config entry.
async def async_setup_entry(hass, entry, async_add_entities) -> None: """Set up TotalConnect device sensors based on a config entry.""" sensors = [] client_locations = hass.data[DOMAIN][entry.entry_id].locations for location_id, location in client_locations.items(): for zone_id, zone in locati...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", "->", "None", ":", "sensors", "=", "[", "]", "client_locations", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ".", "locat...
[ 11, 0 ]
[ 21, 37 ]
python
en
['en', 'en', 'en']
True
TotalConnectBinarySensor.__init__
(self, zone_id, location_id, zone)
Initialize the TotalConnect status.
Initialize the TotalConnect status.
def __init__(self, zone_id, location_id, zone): """Initialize the TotalConnect status.""" self._zone_id = zone_id self._location_id = location_id self._zone = zone self._name = self._zone.description self._unique_id = f"{location_id} {zone_id}" self._is_on = None ...
[ "def", "__init__", "(", "self", ",", "zone_id", ",", "location_id", ",", "zone", ")", ":", "self", ".", "_zone_id", "=", "zone_id", "self", ".", "_location_id", "=", "location_id", "self", ".", "_zone", "=", "zone", "self", ".", "_name", "=", "self", "...
[ 27, 4 ]
[ 36, 35 ]
python
en
['en', 'en', 'en']
True
TotalConnectBinarySensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 39, 4 ]
[ 41, 30 ]
python
en
['en', 'la', 'en']
True
TotalConnectBinarySensor.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 44, 4 ]
[ 46, 25 ]
python
en
['en', 'en', 'en']
True
TotalConnectBinarySensor.update
(self)
Return the state of the device.
Return the state of the device.
def update(self): """Return the state of the device.""" self._is_tampered = self._zone.is_tampered() self._is_low_battery = self._zone.is_low_battery() if self._zone.is_faulted() or self._zone.is_triggered(): self._is_on = True else: self._is_on = False
[ "def", "update", "(", "self", ")", ":", "self", ".", "_is_tampered", "=", "self", ".", "_zone", ".", "is_tampered", "(", ")", "self", ".", "_is_low_battery", "=", "self", ".", "_zone", ".", "is_low_battery", "(", ")", "if", "self", ".", "_zone", ".", ...
[ 48, 4 ]
[ 56, 31 ]
python
en
['en', 'en', 'en']
True
TotalConnectBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 59, 4 ]
[ 61, 26 ]
python
en
['en', 'fy', 'en']
True
TotalConnectBinarySensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" if self._zone.is_type_security(): return DEVICE_CLASS_DOOR if self._zone.is_type_fire(): return DEVICE_CLASS_SMOKE if self._zone.is_type_carbon_monoxide(): re...
[ "def", "device_class", "(", "self", ")", ":", "if", "self", ".", "_zone", ".", "is_type_security", "(", ")", ":", "return", "DEVICE_CLASS_DOOR", "if", "self", ".", "_zone", ".", "is_type_fire", "(", ")", ":", "return", "DEVICE_CLASS_SMOKE", "if", "self", "...
[ 64, 4 ]
[ 72, 19 ]
python
en
['en', 'en', 'en']
True
TotalConnectBinarySensor.extra_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def extra_state_attributes(self): """Return the state attributes.""" attributes = { "zone_id": self._zone_id, "location_id": self._location_id, "low_battery": self._is_low_battery, "tampered": self._is_tampered, } return attributes
[ "def", "extra_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "\"zone_id\"", ":", "self", ".", "_zone_id", ",", "\"location_id\"", ":", "self", ".", "_location_id", ",", "\"low_battery\"", ":", "self", ".", "_is_low_battery", ",", "\"tampered\"...
[ 75, 4 ]
[ 83, 25 ]
python
en
['en', 'en', 'en']
True
async_attach_trigger
( hass, config, action, automation_info, *, platform_type: str = "zone" )
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger( hass, config, action, automation_info, *, platform_type: str = "zone" ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" trigger_data = automation_info["trigger_data"] entity_id = config.get(CONF_ENTITY_ID) zone_entity_id = config.get(CONF_ZONE...
[ "async", "def", "async_attach_trigger", "(", "hass", ",", "config", ",", "action", ",", "automation_info", ",", "*", ",", "platform_type", ":", "str", "=", "\"zone\"", ")", "->", "CALLBACK_TYPE", ":", "trigger_data", "=", "automation_info", "[", "\"trigger_data\...
[ 35, 0 ]
[ 89, 84 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Return a BT Smart Hub scanner if successful.
Return a BT Smart Hub scanner if successful.
def get_scanner(hass, config): """Return a BT Smart Hub scanner if successful.""" info = config[DOMAIN] smarthub_client = BTSmartHub( router_ip=info[CONF_HOST], smarthub_model=info.get(CONF_SMARTHUB_MODEL) ) scanner = BTSmartHubScanner(smarthub_client) return scanner if scanner.success_i...
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "info", "=", "config", "[", "DOMAIN", "]", "smarthub_client", "=", "BTSmartHub", "(", "router_ip", "=", "info", "[", "CONF_HOST", "]", ",", "smarthub_model", "=", "info", ".", "get", "(", "CONF_...
[ 28, 0 ]
[ 35, 52 ]
python
en
['en', 'co', 'en']
True
_create_device
(data)
Create new device from the dict.
Create new device from the dict.
def _create_device(data): """Create new device from the dict.""" ip_address = data.get("IPAddress") mac = data.get("PhysAddress") host = data.get("UserHostName") status = data.get("Active") name = data.get("name") return _Device(ip_address, mac, host, status, name)
[ "def", "_create_device", "(", "data", ")", ":", "ip_address", "=", "data", ".", "get", "(", "\"IPAddress\"", ")", "mac", "=", "data", ".", "get", "(", "\"PhysAddress\"", ")", "host", "=", "data", ".", "get", "(", "\"UserHostName\"", ")", "status", "=", ...
[ 38, 0 ]
[ 45, 55 ]
python
en
['en', 'en', 'en']
True
BTSmartHubScanner.__init__
(self, smarthub_client)
Initialise the scanner.
Initialise the scanner.
def __init__(self, smarthub_client): """Initialise the scanner.""" self.smarthub = smarthub_client self.last_results = [] self.success_init = False # Test the router is accessible data = self.get_bt_smarthub_data() if data: self.success_init = True ...
[ "def", "__init__", "(", "self", ",", "smarthub_client", ")", ":", "self", ".", "smarthub", "=", "smarthub_client", "self", ".", "last_results", "=", "[", "]", "self", ".", "success_init", "=", "False", "# Test the router is accessible", "data", "=", "self", "....
[ 54, 4 ]
[ 65, 76 ]
python
en
['en', 'en', 'en']
True
BTSmartHubScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [device.mac for device in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 67, 4 ]
[ 70, 59 ]
python
en
['en', 'en', 'en']
True
BTSmartHubScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if not self.last_results: return None for result_device in self.last_results: if result_device.mac == device: return result_device.name or result_device....
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "not", "self", ".", "last_results", ":", "return", "None", "for", "result_device", "in", "self", ".", "last_results", ":", "if", "result_device", ".", "mac", "==", "device", ":", "return...
[ 72, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
BTSmartHubScanner._update_info
(self)
Ensure the information from the BT Smart Hub is up to date.
Ensure the information from the BT Smart Hub is up to date.
def _update_info(self): """Ensure the information from the BT Smart Hub is up to date.""" if not self.success_init: return _LOGGER.info("Scanning") data = self.get_bt_smarthub_data() if not data: _LOGGER.warning("Error scanning devices") retur...
[ "def", "_update_info", "(", "self", ")", ":", "if", "not", "self", ".", "success_init", ":", "return", "_LOGGER", ".", "info", "(", "\"Scanning\"", ")", "data", "=", "self", ".", "get_bt_smarthub_data", "(", ")", "if", "not", "data", ":", "_LOGGER", ".",...
[ 81, 4 ]
[ 91, 32 ]
python
en
['en', 'en', 'en']
True
BTSmartHubScanner.get_bt_smarthub_data
(self)
Retrieve data from BT Smart Hub and return parsed result.
Retrieve data from BT Smart Hub and return parsed result.
def get_bt_smarthub_data(self): """Retrieve data from BT Smart Hub and return parsed result.""" # Request data from bt smarthub into a list of dicts. data = self.smarthub.get_devicelist(only_active_devices=True) return [_create_device(d) for d in data if d.get("PhysAddress")]
[ "def", "get_bt_smarthub_data", "(", "self", ")", ":", "# Request data from bt smarthub into a list of dicts.", "data", "=", "self", ".", "smarthub", ".", "get_devicelist", "(", "only_active_devices", "=", "True", ")", "return", "[", "_create_device", "(", "d", ")", ...
[ 93, 4 ]
[ 97, 72 ]
python
en
['en', 'en', 'en']
True
test_config_entry_withings_api
(hass: HomeAssistant)
Test ConfigEntryWithingsApi.
Test ConfigEntryWithingsApi.
async def test_config_entry_withings_api(hass: HomeAssistant) -> None: """Test ConfigEntryWithingsApi.""" config_entry = MockConfigEntry( data={"token": {"access_token": "mock_access_token", "expires_at": 1111111}} ) config_entry.add_to_hass(hass) implementation_mock = MagicMock(spec=Abstra...
[ "async", "def", "test_config_entry_withings_api", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "config_entry", "=", "MockConfigEntry", "(", "data", "=", "{", "\"token\"", ":", "{", "\"access_token\"", ":", "\"mock_access_token\"", ",", "\"expires_at\""...
[ 29, 0 ]
[ 53, 49 ]
python
en
['en', 'zu', 'en']
False
test_webhook_post
( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, user_id: int, arg_user_id: Any, arg_appli: Any, expected_code: int, current_request_with_host, )
Test webhook callback.
Test webhook callback.
async def test_webhook_post( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, user_id: int, arg_user_id: Any, arg_appli: Any, expected_code: int, current_request_with_host, ) -> None: """Test webhook callback.""" person0 = new_profile_config("person0", us...
[ "async", "def", "test_webhook_post", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ",", "aiohttp_client", ",", "user_id", ":", "int", ",", "arg_user_id", ":", "Any", ",", "arg_appli", ":", "Any", ",", "expected_code", ":",...
[ 68, 0 ]
[ 103, 40 ]
python
en
['en', 'zu', 'en']
True
test_webhook_head
( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, current_request_with_host, )
Test head method on webhook view.
Test head method on webhook view.
async def test_webhook_head( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, current_request_with_host, ) -> None: """Test head method on webhook view.""" person0 = new_profile_config("person0", 0) await component_factory.configure_component(profile_configs=(person...
[ "async", "def", "test_webhook_head", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ",", "aiohttp_client", ",", "current_request_with_host", ",", ")", "->", "None", ":", "person0", "=", "new_profile_config", "(", "\"person0\"", ...
[ 106, 0 ]
[ 121, 29 ]
python
en
['en', 'et', 'en']
True
test_webhook_put
( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, current_request_with_host, )
Test webhook callback.
Test webhook callback.
async def test_webhook_put( hass: HomeAssistant, component_factory: ComponentFactory, aiohttp_client, current_request_with_host, ) -> None: """Test webhook callback.""" person0 = new_profile_config("person0", 0) await component_factory.configure_component(profile_configs=(person0,)) awa...
[ "async", "def", "test_webhook_put", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ",", "aiohttp_client", ",", "current_request_with_host", ",", ")", "->", "None", ":", "person0", "=", "new_profile_config", "(", "\"person0\"", ...
[ 124, 0 ]
[ 146, 28 ]
python
en
['en', 'zu', 'en']
True
test_data_manager_webhook_subscription
( hass: HomeAssistant, component_factory: ComponentFactory, aioclient_mock: AiohttpClientMocker, )
Test data manager webhook subscriptions.
Test data manager webhook subscriptions.
async def test_data_manager_webhook_subscription( hass: HomeAssistant, component_factory: ComponentFactory, aioclient_mock: AiohttpClientMocker, ) -> None: """Test data manager webhook subscriptions.""" person0 = new_profile_config("person0", 0) await component_factory.configure_component(profil...
[ "async", "def", "test_data_manager_webhook_subscription", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ",", "aioclient_mock", ":", "AiohttpClientMocker", ",", ")", "->", "None", ":", "person0", "=", "new_profile_config", "(", "...
[ 149, 0 ]
[ 244, 5 ]
python
en
['fr', 'en', 'en']
True
simple_queue
()
Fixture that get the queue.
Fixture that get the queue.
def simple_queue(): """Fixture that get the queue.""" simple_queue_fixed = queue.SimpleQueue() with patch( "homeassistant.components.system_log.queue.SimpleQueue", return_value=simple_queue_fixed, ): yield simple_queue_fixed
[ "def", "simple_queue", "(", ")", ":", "simple_queue_fixed", "=", "queue", ".", "SimpleQueue", "(", ")", "with", "patch", "(", "\"homeassistant.components.system_log.queue.SimpleQueue\"", ",", "return_value", "=", "simple_queue_fixed", ",", ")", ":", "yield", "simple_q...
[ 17, 0 ]
[ 24, 32 ]
python
en
['en', 'nl', 'en']
True
get_error_log
(hass, hass_client, expected_count)
Fetch all entries from system_log via the API.
Fetch all entries from system_log via the API.
async def get_error_log(hass, hass_client, expected_count): """Fetch all entries from system_log via the API.""" client = await hass_client() resp = await client.get("/api/error/all") assert resp.status == 200 data = await resp.json() assert len(data) == expected_count return data
[ "async", "def", "get_error_log", "(", "hass", ",", "hass_client", ",", "expected_count", ")", ":", "client", "=", "await", "hass_client", "(", ")", "resp", "=", "await", "client", ".", "get", "(", "\"/api/error/all\"", ")", "assert", "resp", ".", "status", ...
[ 37, 0 ]
[ 47, 15 ]
python
en
['en', 'pt', 'en']
True
assert_log
(log, exception, message, level)
Assert that specified values are in a specific log entry.
Assert that specified values are in a specific log entry.
def assert_log(log, exception, message, level): """Assert that specified values are in a specific log entry.""" if not isinstance(message, list): message = [message] assert log["name"] == "test_logger" assert exception in log["exception"] assert message == log["message"] assert level ==...
[ "def", "assert_log", "(", "log", ",", "exception", ",", "message", ",", "level", ")", ":", "if", "not", "isinstance", "(", "message", ",", "list", ")", ":", "message", "=", "[", "message", "]", "assert", "log", "[", "\"name\"", "]", "==", "\"test_logge...
[ 57, 0 ]
[ 66, 29 ]
python
en
['en', 'en', 'en']
True
get_frame
(name)
Get log stack frame.
Get log stack frame.
def get_frame(name): """Get log stack frame.""" return (name, 5, None, None)
[ "def", "get_frame", "(", "name", ")", ":", "return", "(", "name", ",", "5", ",", "None", ",", "None", ")" ]
[ 69, 0 ]
[ 71, 32 ]
python
da
['da', 'da', 'en']
True
test_normal_logs
(hass, simple_queue, hass_client)
Test that debug and info are not logged.
Test that debug and info are not logged.
async def test_normal_logs(hass, simple_queue, hass_client): """Test that debug and info are not logged.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.debug("debug") _LOGGER.info("info") await _async_block_until_queue_empty(hass, simple_queue) # Assert done by g...
[ "async", "def", "test_normal_logs", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "debug", "(", "\"debug\"", ")", "_LOG...
[ 74, 0 ]
[ 83, 45 ]
python
en
['en', 'en', 'en']
True
test_exception
(hass, simple_queue, hass_client)
Test that exceptions are logged and retrieved correctly.
Test that exceptions are logged and retrieved correctly.
async def test_exception(hass, simple_queue, hass_client): """Test that exceptions are logged and retrieved correctly.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _generate_and_log_exception("exception message", "log message") await _async_block_until_queue_empty(hass, simple_q...
[ "async", "def", "test_exception", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_generate_and_log_exception", "(", "\"exception message\"", ...
[ 86, 0 ]
[ 93, 64 ]
python
en
['en', 'en', 'en']
True
test_warning
(hass, simple_queue, hass_client)
Test that warning are logged and retrieved correctly.
Test that warning are logged and retrieved correctly.
async def test_warning(hass, simple_queue, hass_client): """Test that warning are logged and retrieved correctly.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.warning("warning message") await _async_block_until_queue_empty(hass, simple_queue) log = (await get_error_...
[ "async", "def", "test_warning", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "warning", "(", "\"warning message\"", ")",...
[ 96, 0 ]
[ 103, 53 ]
python
en
['en', 'en', 'en']
True
test_error
(hass, simple_queue, hass_client)
Test that errors are logged and retrieved correctly.
Test that errors are logged and retrieved correctly.
async def test_error(hass, simple_queue, hass_client): """Test that errors are logged and retrieved correctly.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.error("error message") await _async_block_until_queue_empty(hass, simple_queue) log = (await get_error_log(has...
[ "async", "def", "test_error", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "error", "(", "\"error message\"", ")", "aw...
[ 106, 0 ]
[ 113, 49 ]
python
en
['en', 'en', 'en']
True
test_config_not_fire_event
(hass, simple_queue)
Test that errors are not posted as events with default config.
Test that errors are not posted as events with default config.
async def test_config_not_fire_event(hass, simple_queue): """Test that errors are not posted as events with default config.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) events = [] @callback def event_listener(event): """Listen to events of type system_log_event."""...
[ "async", "def", "test_config_not_fire_event", "(", "hass", ",", "simple_queue", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "events", "=", "[", "]", "@", "callback", "def", "event_listener"...
[ 116, 0 ]
[ 131, 27 ]
python
en
['en', 'en', 'en']
True
test_error_posted_as_event
(hass, simple_queue)
Test that error are posted as events.
Test that error are posted as events.
async def test_error_posted_as_event(hass, simple_queue): """Test that error are posted as events.""" await async_setup_component( hass, system_log.DOMAIN, {"system_log": {"max_entries": 2, "fire_event": True}} ) events = [] @callback def event_listener(event): """Listen to even...
[ "async", "def", "test_error_posted_as_event", "(", "hass", ",", "simple_queue", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "{", "\"system_log\"", ":", "{", "\"max_entries\"", ":", "2", ",", "\"fire_event\"", "...
[ 134, 0 ]
[ 152, 60 ]
python
en
['en', 'en', 'en']
True
test_critical
(hass, simple_queue, hass_client)
Test that critical are logged and retrieved correctly.
Test that critical are logged and retrieved correctly.
async def test_critical(hass, simple_queue, hass_client): """Test that critical are logged and retrieved correctly.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.critical("critical message") await _async_block_until_queue_empty(hass, simple_queue) log = (await get_er...
[ "async", "def", "test_critical", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "critical", "(", "\"critical message\"", "...
[ 155, 0 ]
[ 162, 55 ]
python
en
['en', 'en', 'en']
True
test_remove_older_logs
(hass, simple_queue, hass_client)
Test that older logs are rotated out.
Test that older logs are rotated out.
async def test_remove_older_logs(hass, simple_queue, hass_client): """Test that older logs are rotated out.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.error("error message 1") _LOGGER.error("error message 2") _LOGGER.error("error message 3") await _async_block_...
[ "async", "def", "test_remove_older_logs", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "error", "(", "\"error message 1\""...
[ 165, 0 ]
[ 175, 54 ]
python
en
['en', 'en', 'en']
True
log_msg
(nr=2)
Log an error at same line.
Log an error at same line.
def log_msg(nr=2): """Log an error at same line.""" _LOGGER.error("error message %s", nr)
[ "def", "log_msg", "(", "nr", "=", "2", ")", ":", "_LOGGER", ".", "error", "(", "\"error message %s\"", ",", "nr", ")" ]
[ 178, 0 ]
[ 180, 41 ]
python
da
['da', 'lb', 'en']
False
test_dedupe_logs
(hass, simple_queue, hass_client)
Test that duplicate log entries are dedupe.
Test that duplicate log entries are dedupe.
async def test_dedupe_logs(hass, simple_queue, hass_client): """Test that duplicate log entries are dedupe.""" await async_setup_component(hass, system_log.DOMAIN, {}) _LOGGER.error("error message 1") log_msg() log_msg("2-2") _LOGGER.error("error message 3") await _async_block_until_queue_em...
[ "async", "def", "test_dedupe_logs", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "{", "}", ")", "_LOGGER", ".", "error", "(", "\"error message 1\"", ")", ...
[ 183, 0 ]
[ 222, 5 ]
python
en
['en', 'en', 'en']
True
test_clear_logs
(hass, simple_queue, hass_client)
Test that the log can be cleared via a service call.
Test that the log can be cleared via a service call.
async def test_clear_logs(hass, simple_queue, hass_client): """Test that the log can be cleared via a service call.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.error("error message") await _async_block_until_queue_empty(hass, simple_queue) await hass.services.async...
[ "async", "def", "test_clear_logs", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "error", "(", "\"error message\"", ")", ...
[ 225, 0 ]
[ 235, 45 ]
python
en
['en', 'en', 'en']
True
test_write_log
(hass)
Test that error propagates to logger.
Test that error propagates to logger.
async def test_write_log(hass): """Test that error propagates to logger.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) logger = MagicMock() with patch("logging.getLogger", return_value=logger) as mock_logging: await hass.services.async_call( system_log.DOMAIN,...
[ "async", "def", "test_write_log", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "logger", "=", "MagicMock", "(", ")", "with", "patch", "(", "\"logging.getLogger\"", ",", "retur...
[ 238, 0 ]
[ 248, 65 ]
python
en
['en', 'el-Latn', 'en']
True
test_write_choose_logger
(hass)
Test that correct logger is chosen.
Test that correct logger is chosen.
async def test_write_choose_logger(hass): """Test that correct logger is chosen.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) with patch("logging.getLogger") as mock_logging: await hass.services.async_call( system_log.DOMAIN, system_log.SERVICE_WRITE,...
[ "async", "def", "test_write_choose_logger", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "with", "patch", "(", "\"logging.getLogger\"", ")", "as", "mock_logging", ":", "await", ...
[ 251, 0 ]
[ 261, 52 ]
python
en
['en', 'en', 'en']
True
test_write_choose_level
(hass)
Test that correct logger is chosen.
Test that correct logger is chosen.
async def test_write_choose_level(hass): """Test that correct logger is chosen.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) logger = MagicMock() with patch("logging.getLogger", return_value=logger): await hass.services.async_call( system_log.DOMAIN, ...
[ "async", "def", "test_write_choose_level", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "logger", "=", "MagicMock", "(", ")", "with", "patch", "(", "\"logging.getLogger\"", ",",...
[ 264, 0 ]
[ 275, 65 ]
python
en
['en', 'en', 'en']
True
test_unknown_path
(hass, simple_queue, hass_client)
Test error logged from unknown path.
Test error logged from unknown path.
async def test_unknown_path(hass, simple_queue, hass_client): """Test error logged from unknown path.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) _LOGGER.findCaller = MagicMock(return_value=("unknown_path", 0, None, None)) _LOGGER.error("error message") await _async_block_u...
[ "async", "def", "test_unknown_path", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "_LOGGER", ".", "findCaller", "=", "MagicMock", "(", ...
[ 278, 0 ]
[ 285, 47 ]
python
en
['en', 'en', 'en']
True
async_log_error_from_test_path
(hass, path, sq)
Log error while mocking the path.
Log error while mocking the path.
async def async_log_error_from_test_path(hass, path, sq): """Log error while mocking the path.""" call_path = "internal_path.py" with patch.object( _LOGGER, "findCaller", MagicMock(return_value=(call_path, 0, None, None)) ), patch( "traceback.extract_stack", MagicMock( ...
[ "async", "def", "async_log_error_from_test_path", "(", "hass", ",", "path", ",", "sq", ")", ":", "call_path", "=", "\"internal_path.py\"", "with", "patch", ".", "object", "(", "_LOGGER", ",", "\"findCaller\"", ",", "MagicMock", "(", "return_value", "=", "(", "...
[ 288, 0 ]
[ 305, 54 ]
python
en
['en', 'en', 'en']
True
test_homeassistant_path
(hass, simple_queue, hass_client)
Test error logged from Home Assistant path.
Test error logged from Home Assistant path.
async def test_homeassistant_path(hass, simple_queue, hass_client): """Test error logged from Home Assistant path.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) with patch( "homeassistant.components.system_log.HOMEASSISTANT_PATH", new=["venv_path/homeassistant"], ...
[ "async", "def", "test_homeassistant_path", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "with", "patch", "(", "\"homeassistant.components.sy...
[ 308, 0 ]
[ 319, 57 ]
python
en
['en', 'en', 'en']
True
test_config_path
(hass, simple_queue, hass_client)
Test error logged from config path.
Test error logged from config path.
async def test_config_path(hass, simple_queue, hass_client): """Test error logged from config path.""" await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG) with patch.object(hass.config, "config_dir", new="config"): await async_log_error_from_test_path( hass, "config/custom...
[ "async", "def", "test_config_path", "(", "hass", ",", "simple_queue", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "system_log", ".", "DOMAIN", ",", "BASIC_CONFIG", ")", "with", "patch", ".", "object", "(", "hass", ".", "...
[ 322, 0 ]
[ 330, 59 ]
python
en
['en', 'en', 'en']
True
Pass
(*_a, **_kw)
Do nothing.
Do nothing.
def Pass(*_a, **_kw): """Do nothing.""" pass
[ "def", "Pass", "(", "*", "_a", ",", "*", "*", "_kw", ")", ":", "pass" ]
[ 87, 0 ]
[ 89, 8 ]
python
en
['en', 'zu', 'en']
False
Truth
(*_a, **_kw)
Always true.
Always true.
def Truth(*_a, **_kw): """Always true.""" return True
[ "def", "Truth", "(", "*", "_a", ",", "*", "*", "_kw", ")", ":", "return", "True" ]
[ 92, 0 ]
[ 94, 15 ]
python
en
['en', 'de', 'en']
False
Bomb
(*a, **kw)
Always raise.
Always raise.
def Bomb(*a, **kw): """Always raise.""" raise AssertionError('Should not happen', a, kw)
[ "def", "Bomb", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "raise", "AssertionError", "(", "'Should not happen'", ",", "a", ",", "kw", ")" ]
[ 97, 0 ]
[ 99, 52 ]
python
fi
['fi', 'fi', 'en']
False
ReadAllTest.test_read_more
(self)
Read lines until we clear the buffer, noting there may be more.
Read lines until we clear the buffer, noting there may be more.
def test_read_more(self): """Read lines until we clear the buffer, noting there may be more.""" lines = [] total = 10 def more_lines(*_a, **_kw): if len(lines) < total: return [self], [], [] return [], [], [] with Stub(select, 'select', mor...
[ "def", "test_read_more", "(", "self", ")", ":", "lines", "=", "[", "]", "total", "=", "10", "def", "more_lines", "(", "*", "_a", ",", "*", "*", "_kw", ")", ":", "if", "len", "(", "lines", ")", "<", "total", ":", "return", "[", "self", "]", ",",...
[ 117, 4 ]
[ 131, 41 ]
python
en
['en', 'en', 'en']
True
ReadAllTest.test_read_expired
(self)
Read nothing as we are expired, noting there may be more.
Read nothing as we are expired, noting there may be more.
def test_read_expired(self): """Read nothing as we are expired, noting there may be more.""" lines = [] with Stub(select, 'select', lambda *a, **kw: ([], [], [])): done = bootstrap.read_all(self.ended, self, lines.append) self.assertFalse(done) self.assertFalse(lines...
[ "def", "test_read_expired", "(", "self", ")", ":", "lines", "=", "[", "]", "with", "Stub", "(", "select", ",", "'select'", ",", "lambda", "*", "a", ",", "*", "*", "kw", ":", "(", "[", "]", ",", "[", "]", ",", "[", "]", ")", ")", ":", "done", ...
[ 133, 4 ]
[ 140, 31 ]
python
en
['en', 'en', 'en']
True
ReadAllTest.test_read_end
(self)
Note we reached the end of the stream.
Note we reached the end of the stream.
def test_read_end(self): """Note we reached the end of the stream.""" lines = [] with Stub(select, 'select', lambda *a, **kw: ([self], [], [])): with Stub(self, 'readline', lambda: ''): done = bootstrap.read_all(self.endless, self, lines.append) self.assertTr...
[ "def", "test_read_end", "(", "self", ")", ":", "lines", "=", "[", "]", "with", "Stub", "(", "select", ",", "'select'", ",", "lambda", "*", "a", ",", "*", "*", "kw", ":", "(", "[", "self", "]", ",", "[", "]", ",", "[", "]", ")", ")", ":", "w...
[ 142, 4 ]
[ 149, 29 ]
python
en
['en', 'en', 'en']
True
TerminateTest.test_terminate_later
(self)
Do nothing if end is in the future.
Do nothing if end is in the future.
def test_terminate_later(self): """Do nothing if end is in the future.""" timeout = bootstrap.terminate(time.time() + 50, self, False) self.assertFalse(timeout)
[ "def", "test_terminate_later", "(", "self", ")", ":", "timeout", "=", "bootstrap", ".", "terminate", "(", "time", ".", "time", "(", ")", "+", "50", ",", "self", ",", "False", ")", "self", ".", "assertFalse", "(", "timeout", ")" ]
[ 172, 4 ]
[ 175, 33 ]
python
en
['en', 'en', 'en']
True
TerminateTest.test_terminate_never
(self)
Do nothing if end is zero.
Do nothing if end is zero.
def test_terminate_never(self): """Do nothing if end is zero.""" timeout = bootstrap.terminate(0, self, False) self.assertFalse(timeout)
[ "def", "test_terminate_never", "(", "self", ")", ":", "timeout", "=", "bootstrap", ".", "terminate", "(", "0", ",", "self", ",", "False", ")", "self", ".", "assertFalse", "(", "timeout", ")" ]
[ 177, 4 ]
[ 180, 33 ]
python
en
['en', 'en', 'en']
True
TerminateTest.test_terminate_terminate
(self)
Terminate pid if after end and kill is false.
Terminate pid if after end and kill is false.
def test_terminate_terminate(self): """Terminate pid if after end and kill is false.""" timeout = bootstrap.terminate(time.time() - 50, self, False) self.assertTrue(timeout) self.assertFalse(self.killed) self.assertTrue(self.terminated)
[ "def", "test_terminate_terminate", "(", "self", ")", ":", "timeout", "=", "bootstrap", ".", "terminate", "(", "time", ".", "time", "(", ")", "-", "50", ",", "self", ",", "False", ")", "self", ".", "assertTrue", "(", "timeout", ")", "self", ".", "assert...
[ 182, 4 ]
[ 187, 40 ]
python
en
['en', 'en', 'en']
True
TerminateTest.test_terminate_kill
(self)
Kill process group if after end and kill is true.
Kill process group if after end and kill is true.
def test_terminate_kill(self): """Kill process group if after end and kill is true.""" with Stub(os, 'getpgid', self.getpgid), Stub(os, 'killpg', self.killpg): timeout = bootstrap.terminate(time.time() - 50, self, True) self.assertTrue(timeout) self.assertFalse(self.terminate...
[ "def", "test_terminate_kill", "(", "self", ")", ":", "with", "Stub", "(", "os", ",", "'getpgid'", ",", "self", ".", "getpgid", ")", ",", "Stub", "(", "os", ",", "'killpg'", ",", "self", ".", "killpg", ")", ":", "timeout", "=", "bootstrap", ".", "term...
[ 189, 4 ]
[ 197, 69 ]
python
en
['en', 'en', 'en']
True
SubprocessTest.test_stdin
(self)
Will write to subprocess.stdin.
Will write to subprocess.stdin.
def test_stdin(self): """Will write to subprocess.stdin.""" with self.assertRaises(subprocess.CalledProcessError) as cpe: bootstrap._call(0, ['/bin/bash'], stdin='exit 92') self.assertEqual(92, cpe.exception.returncode)
[ "def", "test_stdin", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "subprocess", ".", "CalledProcessError", ")", "as", "cpe", ":", "bootstrap", ".", "_call", "(", "0", ",", "[", "'/bin/bash'", "]", ",", "stdin", "=", "'exit 92'", ")", ...
[ 203, 4 ]
[ 207, 54 ]
python
en
['en', 'ne', 'en']
True
SubprocessTest.test_check_true
(self)
Raise on non-zero exit codes if check is set.
Raise on non-zero exit codes if check is set.
def test_check_true(self): """Raise on non-zero exit codes if check is set.""" with self.assertRaises(subprocess.CalledProcessError): bootstrap._call(0, FAIL, check=True) bootstrap._call(0, PASS, check=True)
[ "def", "test_check_true", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "subprocess", ".", "CalledProcessError", ")", ":", "bootstrap", ".", "_call", "(", "0", ",", "FAIL", ",", "check", "=", "True", ")", "bootstrap", ".", "_call", "("...
[ 209, 4 ]
[ 214, 44 ]
python
en
['en', 'el-Latn', 'en']
True
SubprocessTest.test_check_default
(self)
Default to check=True.
Default to check=True.
def test_check_default(self): """Default to check=True.""" with self.assertRaises(subprocess.CalledProcessError): bootstrap._call(0, FAIL) bootstrap._call(0, PASS)
[ "def", "test_check_default", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "subprocess", ".", "CalledProcessError", ")", ":", "bootstrap", ".", "_call", "(", "0", ",", "FAIL", ")", "bootstrap", ".", "_call", "(", "0", ",", "PASS", ")" ...
[ 216, 4 ]
[ 221, 32 ]
python
en
['en', 'pt', 'en']
True
SubprocessTest.test_check_false
()
Never raise when check is not set.
Never raise when check is not set.
def test_check_false(): """Never raise when check is not set.""" bootstrap._call(0, FAIL, check=False) bootstrap._call(0, PASS, check=False)
[ "def", "test_check_false", "(", ")", ":", "bootstrap", ".", "_call", "(", "0", ",", "FAIL", ",", "check", "=", "False", ")", "bootstrap", ".", "_call", "(", "0", ",", "PASS", ",", "check", "=", "False", ")" ]
[ 224, 4 ]
[ 227, 45 ]
python
en
['en', 'en', 'en']
True
SubprocessTest.test_output
(self)
Output is returned when requested.
Output is returned when requested.
def test_output(self): """Output is returned when requested.""" cmd = ['/bin/bash', '-c', 'echo hello world'] self.assertEqual( 'hello world\n', bootstrap._call(0, cmd, output=True))
[ "def", "test_output", "(", "self", ")", ":", "cmd", "=", "[", "'/bin/bash'", ",", "'-c'", ",", "'echo hello world'", "]", "self", ".", "assertEqual", "(", "'hello world\\n'", ",", "bootstrap", ".", "_call", "(", "0", ",", "cmd", ",", "output", "=", "True...
[ 229, 4 ]
[ 233, 66 ]
python
en
['en', 'en', 'en']
True
PullRefsTest.test_multiple_no_shas
(self)
Test master,1111,2222.
Test master,1111,2222.
def test_multiple_no_shas(self): """Test master,1111,2222.""" self.assertEqual( bootstrap.pull_ref('master,123,456'), ([ 'master', '+refs/pull/123/head:refs/pr/123', '+refs/pull/456/head:refs/pr/456', ], [ ...
[ "def", "test_multiple_no_shas", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "bootstrap", ".", "pull_ref", "(", "'master,123,456'", ")", ",", "(", "[", "'master'", ",", "'+refs/pull/123/head:refs/pr/123'", ",", "'+refs/pull/456/head:refs/pr/456'", ",", "]...
[ 244, 4 ]
[ 257, 9 ]
python
en
['en', 'de', 'en']
False
ConfigureSshKeyTest.test_empty
(self)
Do not change environ if no ssh key.
Do not change environ if no ssh key.
def test_empty(self): """Do not change environ if no ssh key.""" fake_env = {} with Stub(os, 'environ', fake_env): with bootstrap.configure_ssh_key(''): self.assertFalse(fake_env)
[ "def", "test_empty", "(", "self", ")", ":", "fake_env", "=", "{", "}", "with", "Stub", "(", "os", ",", "'environ'", ",", "fake_env", ")", ":", "with", "bootstrap", ".", "configure_ssh_key", "(", "''", ")", ":", "self", ".", "assertFalse", "(", "fake_en...
[ 295, 4 ]
[ 300, 42 ]
python
en
['gl', 'ht', 'en']
False
CheckoutTest.test_clean
(self)
checkout cleans and resets if asked to.
checkout cleans and resets if asked to.
def test_clean(self): """checkout cleans and resets if asked to.""" fake = FakeSubprocess() with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, REPO, None, PULL, clean=True) self.assertTrue(any( 'clean' in cmd for cmd, _, _ in fake.calls if 'git' in cmd)...
[ "def", "test_clean", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "REPO", ",", "None", ",", "PULL", ",...
[ 326, 4 ]
[ 335, 72 ]
python
en
['en', 'en', 'en']
True
CheckoutTest.test_pull_ref
(self)
checkout fetches the right ref for a pull.
checkout fetches the right ref for a pull.
def test_pull_ref(self): """checkout fetches the right ref for a pull.""" fake = FakeSubprocess() with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, REPO, None, PULL) expected_ref = bootstrap.pull_ref(PULL)[0][0] self.assertTrue(any( expected_re...
[ "def", "test_pull_ref", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "REPO", ",", "None", ",", "PULL", ...
[ 351, 4 ]
[ 359, 79 ]
python
en
['en', 'en', 'en']
True
CheckoutTest.test_branch
(self)
checkout fetches the right ref for a branch.
checkout fetches the right ref for a branch.
def test_branch(self): """checkout fetches the right ref for a branch.""" fake = FakeSubprocess() with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, REPO, BRANCH, None) expected_ref = BRANCH self.assertTrue(any( expected_ref in cmd for cmd, _, _...
[ "def", "test_branch", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "REPO", ",", "BRANCH", ",", "None", ...
[ 361, 4 ]
[ 369, 79 ]
python
en
['en', 'en', 'en']
True
CheckoutTest.test_repo
(self)
checkout initializes and fetches the right repo.
checkout initializes and fetches the right repo.
def test_repo(self): """checkout initializes and fetches the right repo.""" fake = FakeSubprocess() with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, REPO, BRANCH, None) expected_uri = 'https://%s' % REPO self.assertTrue(any( expected_uri in cm...
[ "def", "test_repo", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "REPO", ",", "BRANCH", ",", "None", "...
[ 371, 4 ]
[ 379, 79 ]
python
en
['en', 'en', 'en']
True
CheckoutTest.test_branch_xor_pull
(self)
Either branch or pull specified, not both.
Either branch or pull specified, not both.
def test_branch_xor_pull(self): """Either branch or pull specified, not both.""" with Stub(os, 'chdir', Bomb): with self.assertRaises(ValueError): bootstrap.checkout(Bomb, REPO, REPO, None, None) with self.assertRaises(ValueError): bootstrap.checko...
[ "def", "test_branch_xor_pull", "(", "self", ")", ":", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Bomb", ")", ":", "with", "self", ".", "assertRaises", "(", "ValueError", ")", ":", "bootstrap", ".", "checkout", "(", "Bomb", ",", "REPO", ",", "REPO...
[ 381, 4 ]
[ 387, 66 ]
python
en
['en', 'en', 'en']
True
CheckoutTest.test_happy
(self)
checkout sanity check.
checkout sanity check.
def test_happy(self): """checkout sanity check.""" fake = FakeSubprocess() with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, REPO, BRANCH, None) self.assertTrue(any( '--tags' in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd)) self.assertTru...
[ "def", "test_happy", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "REPO", ",", "BRANCH", ",", "None", ...
[ 389, 4 ]
[ 399, 34 ]
python
en
['en', 'ht', 'en']
True
CheckoutTest.test_repo_path
(self)
checkout repo to different local path.
checkout repo to different local path.
def test_repo_path(self): """checkout repo to different local path.""" fake = FakeSubprocess() repo_path = "foo/bar" with Stub(os, 'chdir', Pass): bootstrap.checkout(fake, REPO, repo_path, BRANCH, None) expected_uri = 'https://%s' % REPO self.assertTrue(any( ...
[ "def", "test_repo_path", "(", "self", ")", ":", "fake", "=", "FakeSubprocess", "(", ")", "repo_path", "=", "\"foo/bar\"", "with", "Stub", "(", "os", ",", "'chdir'", ",", "Pass", ")", ":", "bootstrap", ".", "checkout", "(", "fake", ",", "REPO", ",", "re...
[ 401, 4 ]
[ 413, 75 ]
python
en
['en', 'en', 'en']
True
ParseReposTest.test_bare
(self)
--bare works.
--bare works.
def test_bare(self): """--bare works.""" args = bootstrap.parse_args(['--job=foo', '--bare']) self.assertFalse(bootstrap.parse_repos(args))
[ "def", "test_bare", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--bare'", "]", ")", "self", ".", "assertFalse", "(", "bootstrap", ".", "parse_repos", "(", "args", ")", ")" ]
[ 416, 4 ]
[ 419, 53 ]
python
da
['en', 'da', 'nl']
False
ParseReposTest.test_pull_branch_none
(self)
args.pull and args.branch should be None
args.pull and args.branch should be None
def test_pull_branch_none(self): """args.pull and args.branch should be None""" args = bootstrap.parse_args(['--job=foo', '--bare']) self.assertIsNone(args.pull) self.assertIsNone(args.branch)
[ "def", "test_pull_branch_none", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--bare'", "]", ")", "self", ".", "assertIsNone", "(", "args", ".", "pull", ")", "self", ".", "assertIsNone", "(", "args", ...
[ 421, 4 ]
[ 425, 38 ]
python
en
['en', 'en', 'en']
True
ParseReposTest.test_plain
(self)
--repo=foo equals foo=master.
--repo=foo equals foo=master.
def test_plain(self): """"--repo=foo equals foo=master.""" args = bootstrap.parse_args(['--job=foo', '--repo=foo']) self.assertEqual( {'foo': ('master', '')}, bootstrap.parse_repos(args))
[ "def", "test_plain", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "'master'", ",", "''", ")", "}", ",", "bootstrap",...
[ 427, 4 ]
[ 432, 40 ]
python
en
['en', 'ca', 'en']
True
ParseReposTest.test_branch
(self)
--repo=foo=branch.
--repo=foo=branch.
def test_branch(self): """--repo=foo=branch.""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=this']) self.assertEqual( {'foo': ('this', '')}, bootstrap.parse_repos(args))
[ "def", "test_branch", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=this'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "'this'", ",", "''", ")", "}", ",", "bootstr...
[ 434, 4 ]
[ 439, 40 ]
python
it
['en', 'it', 'it']
False
ParseReposTest.test_branch_commit
(self)
--repo=foo=branch:commit works.
--repo=foo=branch:commit works.
def test_branch_commit(self): """--repo=foo=branch:commit works.""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=this:abcd']) self.assertEqual( {'foo': ('this:abcd', '')}, bootstrap.parse_repos(args))
[ "def", "test_branch_commit", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=this:abcd'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "'this:abcd'", ",", "''", ")", "}", ...
[ 441, 4 ]
[ 446, 40 ]
python
en
['en', 'en', 'en']
False
ParseReposTest.test_parse_repos
(self)
--repo=foo=111,222 works
--repo=foo=111,222 works
def test_parse_repos(self): """--repo=foo=111,222 works""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=111,222']) self.assertEqual( {'foo': ('', '111,222')}, bootstrap.parse_repos(args))
[ "def", "test_parse_repos", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=111,222'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "''", ",", "'111,222'", ")", "}", ",",...
[ 448, 4 ]
[ 453, 40 ]
python
hi
['nl', 'it', 'hi']
False
ParseReposTest.test_pull_branch
(self)
--repo=foo=master,111,222 works
--repo=foo=master,111,222 works
def test_pull_branch(self): """--repo=foo=master,111,222 works""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=master,111,222']) self.assertEqual( {'foo': ('', 'master,111,222')}, bootstrap.parse_repos(args))
[ "def", "test_pull_branch", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=master,111,222'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "''", ",", "'master,111,222'", ")",...
[ 455, 4 ]
[ 460, 40 ]
python
en
['nl', 'it', 'en']
False
ParseReposTest.test_pull_release_branch
(self)
--repo=foo=release-3.14,&a-fancy%_branch+:abcd,222 works
--repo=foo=release-3.14,&a-fancy%_branch+:abcd,222 works
def test_pull_release_branch(self): """--repo=foo=release-3.14,&a-fancy%_branch+:abcd,222 works""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=release-3.14,&a-fancy%_branch+:abcd,222']) self.assertEqual( {'foo': ('', 'release-3.14,&a-fan...
[ "def", "test_pull_release_branch", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=release-3.14,&a-fancy%_branch+:abcd,222'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "''", ...
[ 462, 4 ]
[ 468, 40 ]
python
en
['en', 'en', 'en']
False
ParseReposTest.test_pull_branch_commit
(self)
--repo=foo=master,111,222 works
--repo=foo=master,111,222 works
def test_pull_branch_commit(self): """--repo=foo=master,111,222 works""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=master:aaa,111:bbb,222:ccc']) self.assertEqual( {'foo': ('', 'master:aaa,111:bbb,222:ccc')}, bootstrap.parse...
[ "def", "test_pull_branch_commit", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=master:aaa,111:bbb,222:ccc'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "''", ",", "'maste...
[ 470, 4 ]
[ 476, 40 ]
python
en
['nl', 'it', 'en']
False
ParseReposTest.test_multi_repo
(self)
--repo=foo=master,111,222 bar works
--repo=foo=master,111,222 bar works
def test_multi_repo(self): """--repo=foo=master,111,222 bar works""" args = bootstrap.parse_args(['--job=foo', '--repo=foo=master:aaa,111:bbb,222:ccc', '--repo=bar']) self.assertEqual( { 'foo': ...
[ "def", "test_multi_repo", "(", "self", ")", ":", "args", "=", "bootstrap", ".", "parse_args", "(", "[", "'--job=foo'", ",", "'--repo=foo=master:aaa,111:bbb,222:ccc'", ",", "'--repo=bar'", "]", ")", "self", ".", "assertEqual", "(", "{", "'foo'", ":", "(", "''",...
[ 478, 4 ]
[ 487, 40 ]
python
fil
['nl', 'fil', 'hi']
False
AppendResultTest.test_new_job
(self)
Stat fails when the job doesn't exist.
Stat fails when the job doesn't exist.
def test_new_job(self): """Stat fails when the job doesn't exist.""" gsutil = FakeGSUtil() build = 123 version = 'v.interesting' success = True def fake_stat(*_a, **_kw): raise subprocess.CalledProcessError(1, ['gsutil'], None) gsutil.stat = fake_stat ...
[ "def", "test_new_job", "(", "self", ")", ":", "gsutil", "=", "FakeGSUtil", "(", ")", "build", "=", "123", "version", "=", "'v.interesting'", "success", "=", "True", "def", "fake_stat", "(", "*", "_a", ",", "*", "*", "_kw", ")", ":", "raise", "subproces...
[ 583, 4 ]
[ 594, 39 ]
python
en
['en', 'en', 'en']
True
AppendResultTest.test_collision_cat
(self)
cat fails if the cache has been updated.
cat fails if the cache has been updated.
def test_collision_cat(self): """cat fails if the cache has been updated.""" gsutil = FakeGSUtil() build = 42 version = 'v1' success = False generations = ['555', '444'] orig_stat = gsutil.stat def fake_stat(*a, **kw): gsutil.generation = gener...
[ "def", "test_collision_cat", "(", "self", ")", ":", "gsutil", "=", "FakeGSUtil", "(", ")", "build", "=", "42", "version", "=", "'v1'", "success", "=", "False", "generations", "=", "[", "'555'", ",", "'444'", "]", "orig_stat", "=", "gsutil", ".", "stat", ...
[ 596, 4 ]
[ 617, 80 ]
python
en
['en', 'en', 'en']
True
AppendResultTest.test_collision_upload
(self)
Test when upload_json tries to update an old version.
Test when upload_json tries to update an old version.
def test_collision_upload(self): """Test when upload_json tries to update an old version.""" gsutil = FakeGSUtil() build = 42 version = 'v1' success = False generations = [555, 444] orig = gsutil.upload_json def fake_upload(path, cache, generation): ...
[ "def", "test_collision_upload", "(", "self", ")", ":", "gsutil", "=", "FakeGSUtil", "(", ")", "build", "=", "42", "version", "=", "'v1'", "success", "=", "False", "generations", "=", "[", "555", ",", "444", "]", "orig", "=", "gsutil", ".", "upload_json",...
[ 619, 4 ]
[ 644, 80 ]
python
en
['en', 'en', 'en']
True
FinishTest.test_metadata_version
(self)
Test that we will extract version info from metadata.
Test that we will extract version info from metadata.
def test_metadata_version(self): """Test that we will extract version info from metadata.""" self.check_metadata_version('job-version') self.check_metadata_version('version')
[ "def", "test_metadata_version", "(", "self", ")", ":", "self", ".", "check_metadata_version", "(", "'job-version'", ")", "self", ".", "check_metadata_version", "(", "'version'", ")" ]
[ 718, 4 ]
[ 721, 46 ]
python
en
['en', 'en', 'en']
True
FinishTest.test_skip_upload_artifacts
(self)
Do not upload artifacts dir if it doesn't exist.
Do not upload artifacts dir if it doesn't exist.
def test_skip_upload_artifacts(self): """Do not upload artifacts dir if it doesn't exist.""" paths = FakePath() gsutil = FakeGSUtil() local_artifacts = None build = 123 version = 'v1.terrible' success = True calls = [] with Stub(os.path, 'isdir', l...
[ "def", "test_skip_upload_artifacts", "(", "self", ")", ":", "paths", "=", "FakePath", "(", ")", "gsutil", "=", "FakeGSUtil", "(", ")", "local_artifacts", "=", "None", "build", "=", "123", "version", "=", "'v1.terrible'", "success", "=", "True", "calls", "=",...
[ 780, 4 ]
[ 795, 39 ]
python
en
['en', 'en', 'en']
True
BuildNameTest.test_auto
(self)
Automatically select a build if not done by user.
Automatically select a build if not done by user.
def test_auto(self): """Automatically select a build if not done by user.""" with Stub(os, 'environ', fake_environment()) as fake: bootstrap.build_name(SECONDS) self.assertTrue(fake[bootstrap.BUILD_ENV])
[ "def", "test_auto", "(", "self", ")", ":", "with", "Stub", "(", "os", ",", "'environ'", ",", "fake_environment", "(", ")", ")", "as", "fake", ":", "bootstrap", ".", "build_name", "(", "SECONDS", ")", "self", ".", "assertTrue", "(", "fake", "[", "bootst...
[ 841, 4 ]
[ 845, 54 ]
python
en
['en', 'en', 'en']
True