예제 #1
0
    def test_update_group(self):
        # Setup Expected Response
        name = 'name3373707'
        display_name = 'displayName1615086568'
        parent_name = 'parentName1015022848'
        filter_ = 'filter-1274492040'
        is_cluster = False
        expected_response = {
            'name': name,
            'display_name': display_name,
            'parent_name': parent_name,
            'filter': filter_,
            'is_cluster': is_cluster
        }
        expected_response = group_pb2.Group(**expected_response)

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

        # Setup Request
        group = {}

        response = client.update_group(group)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = group_service_pb2.UpdateGroupRequest(group=group)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #2
0
    def test_create_group(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        parent_name = 'parentName1015022848'
        filter_ = 'filter-1274492040'
        is_cluster = False
        expected_response = {
            'name': name_2,
            'display_name': display_name,
            'parent_name': parent_name,
            'filter': filter_,
            'is_cluster': is_cluster
        }
        expected_response = group_pb2.Group(**expected_response)

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

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

        response = client.create_group(name, group)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = group_service_pb2.CreateGroupRequest(name=name,
                                                                group=group)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #3
0
    def test_get_group(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        parent_name = "parentName1015022848"
        filter_ = "filter-1274492040"
        is_cluster = False
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "parent_name": parent_name,
            "filter": filter_,
            "is_cluster": is_cluster,
        }
        expected_response = group_pb2.Group(**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.GroupServiceClient()

        # Setup Request
        name = client.group_path("[PROJECT]", "[GROUP]")

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

        assert len(channel.requests) == 1
        expected_request = group_service_pb2.GetGroupRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #4
0
    def test_update_group(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        parent_name = "parentName1015022848"
        filter_ = "filter-1274492040"
        is_cluster = False
        expected_response = {
            "name": name,
            "display_name": display_name,
            "parent_name": parent_name,
            "filter": filter_,
            "is_cluster": is_cluster,
        }
        expected_response = group_pb2.Group(**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.GroupServiceClient()

        # Setup Request
        group = {}

        response = client.update_group(group)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = group_service_pb2.UpdateGroupRequest(group=group)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_group(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        parent_name = 'parentName1015022848'
        filter_ = 'filter-1274492040'
        is_cluster = False
        expected_response = {
            'name': name_2,
            'display_name': display_name,
            'parent_name': parent_name,
            'filter': filter_,
            'is_cluster': is_cluster
        }
        expected_response = group_pb2.Group(**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.GroupServiceClient()

        # Setup Request
        name = client.group_path('[PROJECT]', '[GROUP]')

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

        assert len(channel.requests) == 1
        expected_request = group_service_pb2.GetGroupRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request