Skip to content
This repository was archived by the owner on Aug 25, 2026. It is now read-only.
This repository was archived by the owner on Aug 25, 2026. It is now read-only.

Comparison fails for unit tests with timestamps #897

Closed

Description

@busunkim96

This looks like #508, probably appearing again as the current logic checks for a string match of the field.ident and that changed in #851.

________________________________________________ test_set_finding_state_flattened_async _________________________________________________

    @pytest.mark.asyncio
    async def test_set_finding_state_flattened_async():
        client = SecurityCenterAsyncClient(
            credentials=ga_credentials.AnonymousCredentials(),
        )
    
        # Mock the actual call within the gRPC stub, and fake the request.
        with mock.patch.object(
            type(client.transport.set_finding_state), "__call__"
        ) as call:
            # Designate an appropriate return value for the call.
            call.return_value = finding.Finding()
    
            call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(finding.Finding())
            # Call the method with a truthy value for each flattened field,
            # using the keyword arguments to the method.
            response = await client.set_finding_state(
                name="name_value",
                state=finding.Finding.State.ACTIVE,
                start_time=timestamp_pb2.Timestamp(seconds=751),
            )
    
            # Establish that the underlying call was made with the expected
            # request object values.
            assert len(call.mock_calls)
            _, args, _ = call.mock_calls[0]
            assert args[0].name == "name_value"
            assert args[0].state == finding.Finding.State.ACTIVE
>           assert args[0].start_time == timestamp_pb2.Timestamp(seconds=751)
E           assert DatetimeWithNanoseconds(1970, 1, 1, 0, 12, 31, tzinfo=datetime.timezone.utc) == seconds: 751\n
E            +  where DatetimeWithNanoseconds(1970, 1, 1, 0, 12, 31, tzinfo=datetime.timezone.utc) = name: "name_value"\nstate: ACTIVE\nstart_time {\n  seconds: 751\n}\n.start_time
E            +  and   seconds: 751\n = <class 'google.protobuf.timestamp_pb2.Timestamp'>(seconds=751)
E            +    where <class 'google.protobuf.timestamp_pb2.Timestamp'> = timestamp_pb2.Timestamp

tests/unit/gapic/securitycenter_v1beta1/test_security_center.py:3670: AssertionError

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on May 19, 2021
  2. self-assigned this
    on May 19, 2021
  3. added a commit that references this issue on May 20, 2021
    81932a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions