Skip to content

Commit

Permalink
fix: Fix LRO method test and rest test coverage (#1433)
Browse files Browse the repository at this point in the history
This does:
1) fixes LRO method mock value which for watever reason worked under proto 3.x.x (cpp implementaiton) but does not work under proto 4
2) Add `NO COVER` to mock imports in tests as those lines are mutually exclusive depending on the python version it is runniin gunder.

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
vam-google and parthea committed Sep 7, 2022
1 parent a4e3f10 commit c57a93f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import os
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ def test_{{ method_name }}_rest_interceptors(null_interceptor):
]
pre.return_value = request, metadata
{% if not method.void %}
post.return_value = {{ method.output.ident }}
post.return_value = {{ method.output.ident }}()
{% endif %}

client.{{ method_name }}(request, metadata=[("key", "val"), ("cephalopod", "squid"),])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# try/except added for compatibility with python < 3.8
try:
from unittest import mock
from unittest.mock import AsyncMock
except ImportError:
from unittest.mock import AsyncMock # pragma: NO COVER
except ImportError: # pragma: NO COVER
import mock

import grpc
Expand Down

0 comments on commit c57a93f

Please sign in to comment.