예제 #1
0
    def test_create_source(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name,
            "display_name": display_name,
            "description": description,
        }
        expected_response = source_pb2.Source(**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 = securitycenter_v1beta1.SecurityCenterClient()

        # Setup Request
        parent = client.organization_path("[ORGANIZATION]")
        source = {}

        response = client.create_source(parent, source)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = securitycenter_service_pb2.CreateSourceRequest(
            parent=parent, source=source)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #2
0
    def test_create_source(self):
        # Setup Expected Response
        name = 'name3373707'
        display_name = 'displayName1615086568'
        description = 'description-1724546052'
        expected_response = {
            'name': name,
            'display_name': display_name,
            'description': description
        }
        expected_response = source_pb2.Source(**expected_response)

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

        # Setup Request
        parent = client.organization_path('[ORGANIZATION]')
        source = {}

        response = client.create_source(parent, source)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = securitycenter_service_pb2.CreateSourceRequest(
            parent=parent, source=source)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request