def test_create_company(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        external_id = "externalId-1153075697"
        headquarters_address = "headquartersAddress-1879520036"
        hiring_agency = False
        eeo_text = "eeoText-1652097123"
        website_uri = "websiteUri-2118185016"
        career_site_uri = "careerSiteUri1223331861"
        image_uri = "imageUri-877823864"
        suspended = False
        expected_response = {
            "name": name,
            "display_name": display_name,
            "external_id": external_id,
            "headquarters_address": headquarters_address,
            "hiring_agency": hiring_agency,
            "eeo_text": eeo_text,
            "website_uri": website_uri,
            "career_site_uri": career_site_uri,
            "image_uri": image_uri,
            "suspended": suspended,
        }
        expected_response = company_pb2.Company(**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 = talent_v4beta1.CompanyServiceClient()

        # Setup Request
        parent = client.project_path("[PROJECT]")
        company = {}

        response = client.create_company(parent, company)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = company_service_pb2.CreateCompanyRequest(
            parent=parent, company=company
        )
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
コード例 #2
0
    def test_create_company(self):
        # Setup Expected Response
        name = 'name3373707'
        display_name = 'displayName1615086568'
        external_id = 'externalId-1153075697'
        headquarters_address = 'headquartersAddress-1879520036'
        hiring_agency = False
        eeo_text = 'eeoText-1652097123'
        website_uri = 'websiteUri-2118185016'
        career_site_uri = 'careerSiteUri1223331861'
        image_uri = 'imageUri-877823864'
        suspended = False
        expected_response = {
            'name': name,
            'display_name': display_name,
            'external_id': external_id,
            'headquarters_address': headquarters_address,
            'hiring_agency': hiring_agency,
            'eeo_text': eeo_text,
            'website_uri': website_uri,
            'career_site_uri': career_site_uri,
            'image_uri': image_uri,
            'suspended': suspended
        }
        expected_response = company_pb2.Company(**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 = talent_v4beta1.CompanyServiceClient()

        # Setup Request
        parent = client.tenant_path('[PROJECT]', '[TENANT]')
        company = {}

        response = client.create_company(parent, company)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = company_service_pb2.CreateCompanyRequest(
            parent=parent, company=company)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request