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

Unit tests with timestamps fail #508

Closed
busunkim96 opened this issue Jul 10, 2020 · 0 comments · Fixed by #511
Closed

Unit tests with timestamps fail #508

busunkim96 opened this issue Jul 10, 2020 · 0 comments · Fixed by #511
Assignees
Labels
type: cleanup An internal cleanup or hygiene concern.

Comments

@busunkim96
Copy link
Contributor

busunkim96 commented Jul 10, 2020

def test_set_finding_state_flattened():
    client = SecurityCenterClient(credentials=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 the method with a truthy value for each flattened field,
        # using the keyword arguments to the method.
        client.set_finding_state(
            name="name_value",
            state=finding.Finding.State.ACTIVE,
            start_time=timestamp.Timestamp(seconds=751),
        )

        # Establish that the underlying call was made with the expected
        # request object values.
        assert len(call.mock_calls) == 1
        _, 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.Timestamp(seconds=751)

args[0].start_time is a Python datetime object and the assert fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant