def test_update_alert_policy(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        expected_response = {"name": name, "display_name": display_name}
        expected_response = alert_pb2.AlertPolicy(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = monitoring_v3.AlertPolicyServiceClient()

        # Setup Request
        alert_policy = {}

        response = client.update_alert_policy(alert_policy)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = alert_service_pb2.UpdateAlertPolicyRequest(
            alert_policy=alert_policy
        )
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_alert_policy(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        expected_response = {'name': name_2, 'display_name': display_name}
        expected_response = alert_pb2.AlertPolicy(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = monitoring_v3.AlertPolicyServiceClient()

        # Setup Request
        name = client.project_path('[PROJECT]')
        alert_policy = {}

        response = client.create_alert_policy(name, alert_policy)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = alert_service_pb2.CreateAlertPolicyRequest(
            name=name, alert_policy=alert_policy)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_alert_policy(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        expected_response = {'name': name_2, 'display_name': display_name}
        expected_response = alert_pb2.AlertPolicy(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = monitoring_v3.AlertPolicyServiceClient(channel=channel)

        # Setup Request
        name = client.alert_policy_path('[PROJECT]', '[ALERT_POLICY]')

        response = client.get_alert_policy(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = alert_service_pb2.GetAlertPolicyRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_update_alert_policy(self):
        # Setup Expected Response
        name = 'name3373707'
        display_name = 'displayName1615086568'
        expected_response = {'name': name, 'display_name': display_name}
        expected_response = alert_pb2.AlertPolicy(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = monitoring_v3.AlertPolicyServiceClient(channel=channel)

        # Setup Request
        alert_policy = {}

        response = client.update_alert_policy(alert_policy)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = alert_service_pb2.UpdateAlertPolicyRequest(
            alert_policy=alert_policy)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_alert_policy(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        expected_response = {"name": name_2, "display_name": display_name}
        expected_response = alert_pb2.AlertPolicy(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = monitoring_v3.AlertPolicyServiceClient()

        # Setup Request
        name = client.alert_policy_path("[PROJECT]", "[ALERT_POLICY]")

        response = client.get_alert_policy(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = alert_service_pb2.GetAlertPolicyRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request