Skip to content

Commit 980d319

Browse files
committed
update system test for dlp to be compatible with newer version of lib
1 parent 401dda0 commit 980d319

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

dlp/tests/system/gapic/v2/test_system_dlp_service_v2.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,35 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import time
15+
import json
16+
import os
1617

1718
from google.cloud import dlp_v2
1819
from google.cloud.dlp_v2 import enums
1920
from google.cloud.dlp_v2.proto import dlp_pb2
2021

2122

2223
class TestSystemDlpService(object):
24+
25+
def _get_project_id(self):
26+
env_var_name = 'GOOGLE_APPLICATION_CREDENTIALS'
27+
path = os.environ[env_var_name]
28+
json_data=open(path).read()
29+
data = json.loads(json_data)
30+
return data['project_id']
31+
2332
def test_inspect_content(self):
33+
# get project id from json file
34+
project_id = self._get_project_id()
2435

2536
client = dlp_v2.DlpServiceClient()
2637
min_likelihood = enums.Likelihood.POSSIBLE
27-
inspect_config = {'min_likelihood': min_likelihood}
28-
type_ = 'text/plain'
29-
value = 'my phone number is 215-512-1212'
30-
items_element = {'type': type_, 'value': value}
31-
items = [items_element]
32-
response = client.inspect_content(inspect_config, items)
38+
info_types = [{'name': 'FIRST_NAME'}, {'name': 'LAST_NAME'}]
39+
inspect_config = {
40+
'info_types': info_types,
41+
'min_likelihood': min_likelihood,
42+
}
43+
item = {'value': 'Robert Frost'}
44+
parent = client.project_path(project_id)
45+
response = client.inspect_content(parent, inspect_config, item)
46+

0 commit comments

Comments
 (0)