def tests_disarm_user_code_invalid(self): """Test disarm with invalid user code.""" # first test with no issues self.client = create_client() responses = [ RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, RESPONSE_USER_CODE_INVALID, RESPONSE_ARMED_AWAY, ] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system and confirm armed_away assert self.client.arm_away(self.location_id) is True self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is True # now disarm, should fail assert self.client.disarm(self.location_id) is False # should still be armed_away self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is True
def tests_arm_stay_night(self): """Test arm stay night.""" # first test with no issues self.client = create_client() responses = [RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_STAY_NIGHT] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system assert self.client.arm_stay_night(self.location_id) is True # confirm armed_away self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_night() is True # second test with a zone faulted self.client = create_client() responses = [RESPONSE_ARM_FAILED, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_stay_night(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_night() is False assert self.client.locations[ self.location_id].is_disarmed() is True # third test with bad usercode self.client = create_client() responses = [RESPONSE_USER_CODE_INVALID, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_stay_night(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_night() is False assert self.client.locations[ self.location_id].is_disarmed() is True
def run(error, responses, armit, armingstate): client = create_client() location = client.locations[self.location_id] with patch(TCC_REQUEST_METHOD, side_effect=responses): if error: with pytest.raises(error): armit(location) else: armit(location) location.get_panel_meta_data() assert location.arming_state == armingstate
def tests_arm_away(): """Test arm away.""" # first test with no issues client = create_client() location = client.locations[LOCATION_INFO_BASIC_NORMAL["LocationID"]] responses = [RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY] with patch(TCC_REQUEST_METHOD, side_effect=responses): ArmingHelper(location).arm_away() # confirm armed_away location.get_panel_meta_data() assert location.arming_state.is_armed_away() assert location.partitions[1].arming_state.is_armed_away()
def tests_disarm_disarmed(self): """Test attempt to disarm an already disarmed system.""" # Did this once on my Lynx 7000 and it gave result code SUCCESS client = create_client() location = client.locations[self.location_id] responses = [RESPONSE_DISARMED, RESPONSE_SUCCESS, RESPONSE_DISARMED] with patch(TCC_REQUEST_METHOD, side_effect=responses): location.get_panel_meta_data() assert location.arming_state.is_disarmed() # now disarm ArmingHelper(location).disarm() location.get_panel_meta_data() assert location.arming_state.is_disarmed()
def tests_disarm_disarmed(self): """Test attempt to disarm an already disarmed system.""" # Did this once on my Lynx 7000 and it gave result code SUCCESS self.client = create_client() responses = [RESPONSE_DISARMED, RESPONSE_SUCCESS, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_disarmed() is True # now disarm assert self.client.disarm(self.location_id) is True self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_disarmed() is True
def tests_disarm(self): """Test disarm.""" # first test with no issues client = create_client() location = client.locations[self.location_id] responses = [ RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, RESPONSE_DISARM_SUCCESS, RESPONSE_DISARMED, ] with patch(TCC_REQUEST_METHOD, side_effect=responses): # arm the system and confirm armed_away ArmingHelper(location).arm_away() location.get_panel_meta_data() assert location.arming_state.is_armed_away() # now disarm ArmingHelper(location).disarm() location.get_panel_meta_data() assert location.arming_state.is_disarmed()
def tests_disarm_user_code_invalid(self): """Test disarm with invalid user code.""" client = create_client() location = client.locations[self.location_id] responses = [ RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, RESPONSE_USER_CODE_INVALID, RESPONSE_ARMED_AWAY, ] with patch(TCC_REQUEST_METHOD, side_effect=responses): # arm the system and confirm armed_away ArmingHelper(location).arm_away() location.get_panel_meta_data() assert location.arming_state.is_armed_away() with pytest.raises(UsercodeInvalid): ArmingHelper(location).disarm() # should still be armed_away when disarming fails location.get_panel_meta_data() assert location.arming_state.is_armed_away()
def tests_disarm(self): """Test disarm.""" # first test with no issues self.client = create_client() responses = [ RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, RESPONSE_DISARM_SUCCESS, RESPONSE_DISARMED, ] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system and confirm armed_away assert self.client.arm_away(self.location_id) is True self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is True # now disarm assert self.client.disarm(self.location_id) is True self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_disarmed() is True
def tests_disarm_command_failed(self): """Test disarm with command failed.""" # first test with no issues client = create_client() location = client.locations[self.location_id] responses = [ RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, RESPONSE_DISARM_FAILED, RESPONSE_ARMED_AWAY, ] with patch(TCC_REQUEST_METHOD, side_effect=responses): # arm the system and confirm armed_away ArmingHelper(location).arm_away() location.get_panel_meta_data() assert location.arming_state.is_armed_away() # now disarm, should fail with pytest.raises(BadResultCodeError): ArmingHelper(location).disarm() # should still be armed_away location.get_panel_meta_data() assert location.arming_state.is_armed_away()
def setUp(self): """Test setup.""" self.client = create_client() self.location_id = LOCATION_INFO_BASIC_NORMAL["LocationID"]
from attribute_read import attribute_read_tests from attribute_write_values import attribute_write_values_tests, attribute_write_values_two_clients_tests from safety_secure_channels import secure_channels_connect from discovery_get_endpoints import discovery_get_endpoints_tests from client_discovery_server_services import discovery_server_tests from view_basic import browse_tests from translate_browse_path import translate_browse_paths_to_node_ids_tests from common import sUri, create_client from tap_logger import TapLogger from opcua.crypto import security_policies if __name__ == '__main__': # tests with one connexion print('Connecting to', sUri) client = create_client() logger = TapLogger("validation.tap") headerString = "******************* Beginning {0} tests with one connexion *********************" for sp in [SecurityPolicy, security_policies.SecurityPolicyBasic256]: #for sp in [SecurityPolicy]: logger.begin_section("security policy {0}".format( re.split("#", sp.URI)[-1])) try: # secure channel connection secure_channels_connect(client, sp) # discovery server services discovery_server_tests(client, logger) # check endpoints discovery_get_endpoints_tests(client, logger)
#!/usr/bin/env python from common import create_client, link, wait_done, get_url client = create_client('http://localhost:8080') print 'Creating logstash' logstash = client.create_container(name='logstash', imageUuid='docker:cattle/logstash') print 'Creating Kibana' kibana = client.create_container(name='kibana', imageUuid='docker:cattle/kibana', environment=link(es=logstash)) print 'Creating MySQL' db = client.create_container(name='mysql', imageUuid='docker:cattle/mysql') print 'Creating Cattle' cattle = client.create_container(name='cattle', imageUuid='docker:cattle/cattle', environment=link(mysql=db, gelf=logstash)) cattle = wait_done(cattle) print 'phpMyAdmin running at {}/phpmyadmin'.format(get_url(db, '80/tcp')) print 'Kibana running at', get_url(kibana, '80/tcp') print 'Cattle running at', get_url(cattle, '8080/tcp')
print(' Error expected on next read:') # Try to read a node again try: node = client.get_node(nid) value = node.get_value() except: logger.add_test('OPN renew test - read refused after timeout', True) else: logger.add_test('OPN renew test - read refused after timeout', False) if __name__ == '__main__': # tests with one connexion print('Connecting to', sUri) client = create_client() logger = TapLogger("sc_renew.tap") # tests of SC renew with degraded cases headerString = "******************* Beginning {0} test of degraded SC renew *********************" for sp in [SecurityPolicy, security_policies.SecurityPolicyBasic256]: logger.begin_section("security policy {0}".format( re.split("#", sp.URI)[-1])) # secure channel connection print(headerString.format(re.split("#", sp.URI)[-1])) try: secure_channels_connect(client, sp) for i in range(0, 1): secure_channel_renew_nominal(client, logger) secure_channel_renew_test_read_failure(client, logger) finally:
def tests_arm_away(self): """Test arm away.""" # first test with no issues self.client = create_client() responses = [RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should succeed assert self.client.arm_away(self.location_id) is True # confirm armed_away self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is True # second test with a zone faulted self.client = create_client() responses = [RESPONSE_ARM_FAILED, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_away(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is False assert self.client.locations[ self.location_id].is_disarmed() is True # third test with bad usercode self.client = create_client() responses = [RESPONSE_USER_CODE_INVALID, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_away(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is False assert self.client.locations[ self.location_id].is_disarmed() is True # fourth test with 'unavailable' usercode self.client = create_client() responses = [RESPONSE_USER_CODE_UNAVAILABLE, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_away(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is False assert self.client.locations[ self.location_id].is_disarmed() is True # fifth test with 'other' usercode self.client = create_client() responses = [RESPONSE_FEATURE_NOT_SUPPORTED, RESPONSE_DISARMED] with patch("TotalConnectClient.TotalConnectClient.request", side_effect=responses): # arm the system, should fail assert self.client.arm_away(self.location_id) is False # should still be disarmed self.client.get_panel_meta_data(self.location_id) assert self.client.locations[ self.location_id].is_armed_away() is False assert self.client.locations[ self.location_id].is_disarmed() is True