def test_update_component_with_all(self, update_component): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_component_path = 'json_patch' fake_json_patch = 'json_patch' fake_etag = 'etag' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.update_component( fake_digital_twin_id, fake_component_path, fake_json_patch, etag=fake_etag, match_condition=MatchConditions.IfPresent, **fake_kwargs ) update_component.assert_called_with( fake_digital_twin_id, fake_component_path, patch_document=fake_json_patch, if_match='*', etag=fake_etag, match_condition=MatchConditions.IfPresent, **fake_kwargs )
def test_publish_component_telemetry_with_kwargs(self, send_component_telemetry): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_component_path = 'component_path' fake_payload = 'payload' fake_message_id = 'message_id' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.publish_component_telemetry( fake_digital_twin_id, fake_component_path, fake_payload, fake_message_id, **fake_kwargs ) send_component_telemetry.assert_called_with( fake_digital_twin_id, fake_component_path, dt_id=fake_message_id, telemetry=fake_payload, dt_timestamp=mock.ANY, **fake_kwargs )
def test_delete_digital_twin(self, delete): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.delete_digital_twin(fake_digital_twin_id) delete.assert_called_with(fake_digital_twin_id, if_match=None)
def test_list_incoming_relationship(self, list_incoming_relationships): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.list_incoming_relationships(fake_digital_twin_id) list_incoming_relationships.assert_called_with(fake_digital_twin_id)
def test_get_model(self, get_by_id): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_model_id = 'model_id' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.get_model(fake_model_id) get_by_id.assert_called_with(fake_model_id, False)
def test_get_digital_twin(self, get_by_id): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.get_digital_twin(fake_digital_twin_id) get_by_id.assert_called_with(fake_digital_twin_id)
def test_get_digital_twin_with_kwargs(self, get_by_id): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.get_digital_twin(fake_digital_twin_id, **fake_kwargs) get_by_id.assert_called_with(fake_digital_twin_id, **fake_kwargs)
def test_list_event_routes(self, list): fake_endpoint = 'endpoint' fake_credential = 'credential' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.list_event_routes() list.assert_called_with( event_routes_list_options=None )
def test_get_component(self, get_component): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_component_path = 'component_path' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.get_component(fake_digital_twin_id, fake_component_path) get_component.assert_called_with(fake_digital_twin_id, fake_component_path)
def test_delete_digital_twin_with_kwargs(self, delete): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.delete_digital_twin(fake_digital_twin_id, **fake_kwargs) delete.assert_called_with(fake_digital_twin_id, if_match=None, **fake_kwargs)
def test_update_digital_twin(self, update): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_json_patch = 'json_patch' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.update_digital_twin(fake_digital_twin_id, fake_json_patch) update.assert_called_with(fake_digital_twin_id, fake_json_patch, if_match=None)
def test_upsert_digital_twin(self, add): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_digital_twin = 'digital_twin' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.upsert_digital_twin(fake_digital_twin_id, fake_digital_twin) add.assert_called_with(fake_digital_twin_id, fake_digital_twin)
def test_create_models(self, add): fake_endpoint = 'endpoint' fake_credential = 'credential' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.create_models() add.assert_called_with( None )
def test_delete_event_route(self, delete): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_event_route_id = 'event_route_id' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.delete_event_route(fake_event_route_id) delete.assert_called_with( fake_event_route_id )
def test_delete_model(self, delete): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_model_id = 'model_id' fake_model_patch = 'model_patch' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.delete_model(fake_model_id) delete.assert_called_with( fake_model_id )
def test_list_event_routes_with_result_per_page(self, list): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_results_per_page = 42 digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.list_event_routes( results_per_page=fake_results_per_page ) list.assert_called_with( event_routes_list_options={'max_item_count': fake_results_per_page} )
def test_list_event_routes_with_kwargs(self, list): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_results_per_page = 42 fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.list_event_routes(**fake_kwargs) list.assert_called_with( event_routes_list_options=None, **fake_kwargs )
def test_decommission_model(self, update): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_model_id = 'model_id' json_patch = "{ 'op': 'replace', 'path': '/decommissioned', 'value': true }" digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.decommission_model(fake_model_id) update.assert_called_with( fake_model_id, json_patch )
def test_list_models(self, list): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_dependencies_for = 'dependencies_for' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.list_models( fake_dependencies_for ) list.assert_called_with( dependencies_for=fake_dependencies_for, include_model_definition=False, digital_twin_models_list_options=None )
def test_create_models_with_kwargs(self, add): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_models = 'models' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.create_models( fake_models, **fake_kwargs ) add.assert_called_with( fake_models, **fake_kwargs )
def test_upsert_event_route(self, add): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_event_route_id = 'event_route_id' fake_event_route = 'event_route' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.upsert_event_route( fake_event_route_id, fake_event_route ) add.assert_called_with( fake_event_route_id, fake_event_route )
def test_list_models_with_model_result_per_page(self, list): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_dependencies_for = 'dependencies_for' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.list_models( fake_dependencies_for, results_per_page=42 ) list.assert_called_with( dependencies_for=fake_dependencies_for, include_model_definition=False, digital_twin_models_list_options={'max_item_count': 42} )
def test_list_incoming_relationship_with_kwargs(self, list_incoming_relationships): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.list_incoming_relationships( fake_digital_twin_id, **fake_kwargs ) list_incoming_relationships.assert_called_with( fake_digital_twin_id, **fake_kwargs )
def test_get_model_with_model_definition(self, get_by_id): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_model_id = 'model_id' digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.get_model( fake_model_id, include_model_definition=True ) get_by_id.assert_called_with( fake_model_id, True, include_model_definition=True )
def test_upsert_relationship(self, add_relationship): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_relationship_id = 'relationship_id' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.upsert_relationship( fake_digital_twin_id, fake_relationship_id ) add_relationship.assert_called_with( id=fake_digital_twin_id, relationship_id=fake_relationship_id, relationship=None )
def test_publish_telemetry(self, send_telemetry): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_payload = 'payload' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.publish_telemetry( fake_digital_twin_id, fake_payload ) send_telemetry.assert_called_with( fake_digital_twin_id, mock.ANY, telemetry=fake_payload, dt_timestamp=mock.ANY )
def test_get_model_with_model_kwargs(self, get_by_id): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_model_id = 'model_id' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_models_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_models_client.get_model( fake_model_id, include_model_definition=True, **fake_kwargs ) get_by_id.assert_called_with( fake_model_id, True, include_model_definition=True, **fake_kwargs )
def test_upsert_event_route_with_kwargs(self, add): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_event_route_id = 'event_route_id' fake_event_route = 'event_route' fake_kwargs = {'par1_key':'par1_val', 'par2_key':2} digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.upsert_event_route( fake_event_route_id, fake_event_route, **fake_kwargs ) add.assert_called_with( fake_event_route_id, fake_event_route, **fake_kwargs )
def test_delete_digital_twin_with_etag(self, delete): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_etag = 'etag' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.delete_digital_twin( fake_digital_twin_id, etag=fake_etag, match_condition=MatchConditions.IfPresent ) delete.assert_called_with( fake_digital_twin_id, if_match='*', etag=fake_etag, match_condition=MatchConditions.IfPresent )
def test_upsert_relationship_with_relationship(self, update_relationship): fake_endpoint = 'endpoint' fake_credential = 'credential' fake_digital_twin_id = 'digital_twin_id' fake_relationship_id = 'relationship_id' fake_json_patch = 'json_patch' digital_twin_client = DigitalTwinsClient(fake_endpoint, fake_credential) digital_twin_client.update_relationship( fake_digital_twin_id, fake_relationship_id, fake_json_patch ) update_relationship.assert_called_with( id=fake_digital_twin_id, relationship_id=fake_relationship_id, json_patch=fake_json_patch, if_match=None )