示例#1
0
    def test_get_organization_settings(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        enable_asset_discovery = False
        expected_response = {
            "name": name_2,
            "enable_asset_discovery": enable_asset_discovery,
        }
        expected_response = organization_settings_pb2.OrganizationSettings(
            **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
        name = client.organization_settings_path("[ORGANIZATION]")

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

        assert len(channel.requests) == 1
        expected_request = securitycenter_service_pb2.GetOrganizationSettingsRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
示例#2
0
    def test_get_organization_settings(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        enable_asset_discovery = False
        expected_response = {
            'name': name_2,
            'enable_asset_discovery': enable_asset_discovery
        }
        expected_response = organization_settings_pb2.OrganizationSettings(
            **expected_response)

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

        # Setup Request
        name = client.organization_settings_path('[ORGANIZATION]')

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

        assert len(channel.requests) == 1
        expected_request = securitycenter_service_pb2.GetOrganizationSettingsRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request