Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison fails for unit tests with timestamps #897

Closed
busunkim96 opened this issue May 19, 2021 · 0 comments · Fixed by #898
Closed

Comparison fails for unit tests with timestamps #897

busunkim96 opened this issue May 19, 2021 · 0 comments · Fixed by #898
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@busunkim96
Copy link
Contributor

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
@busunkim96 busunkim96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 19, 2021
@busunkim96 busunkim96 self-assigned this May 19, 2021
gcf-merge-on-green bot pushed a commit that referenced this issue May 20, 2021
Fixes #897 

The string ident changed to have an `_pb2` in #851. If there's a more robust way to do this comparison please let me know.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant