コード例 #1
0
    def test_update_organization_settings(self):
        # Setup Expected Response
        name = "name3373707"
        enable_asset_discovery = False
        expected_response = {
            "name": name,
            "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_v1.SecurityCenterClient()

        # Setup Request
        organization_settings = {}

        response = client.update_organization_settings(organization_settings)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = securitycenter_service_pb2.UpdateOrganizationSettingsRequest(
            organization_settings=organization_settings
        )
        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])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = securitycenter_v1.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