diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh index 692bf93e7505..598c4c5772fc 100755 --- a/.kokoro/tests/run_tests.sh +++ b/.kokoro/tests/run_tests.sh @@ -50,7 +50,6 @@ gcloud auth activate-service-account \ export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json source "${KOKORO_GFILE_DIR}/automl_secrets.txt" -cp "${KOKORO_GFILE_DIR}/functions-slack-config.json" "functions/slack/config.json" # For Datalabeling samples to hit the testing endpoint export DATALABELING_ENDPOINT="test-datalabeling.sandbox.googleapis.com:443" diff --git a/functions/pubsub/main.py b/functions/pubsub/main.py index 83d0adcaaefb..e80ea84c8d39 100644 --- a/functions/pubsub/main.py +++ b/functions/pubsub/main.py @@ -46,7 +46,6 @@ def publish(request): 'data': {'message': message}, }) message_bytes = message_json.encode('utf-8') - print(message_bytes) # Publishes a message try: diff --git a/functions/pubsub/main_test.py b/functions/pubsub/main_test.py index 6e9124039cc9..cebf7f54ef37 100644 --- a/functions/pubsub/main_test.py +++ b/functions/pubsub/main_test.py @@ -16,7 +16,6 @@ import os from mock import MagicMock -import pytest import main @@ -24,32 +23,29 @@ FUNCTIONS_TOPIC = os.getenv("FUNCTIONS_TOPIC") -@pytest.mark.skip("broken") def test_functions_pubsub_publish_should_fail_without_params(): request = MagicMock() - request.body.topic = None + request.get_json.return_value = {} response = main.publish(request) assert 'Missing "topic" and/or "subscription" parameter.' in response -@pytest.mark.skip("broken") def test_functions_pubsub_publish_should_publish_message(): request = MagicMock() - request.body.topic = FUNCTIONS_TOPIC - request.body.message = "my_message" + request.get_json.return_value = { + "topic": FUNCTIONS_TOPIC, "message": "my_message" + } response = main.publish(request) assert response == "Message published." -@pytest.mark.skip("broken") def test_functions_pubsub_subscribe_should_print_message(capsys): - pubsub_message = MagicMock() - pubsub_message.data = base64.b64encode(b"Hello, world!") + pubsub_message = {"data": base64.b64encode(b"Hello, world!")} - main.subscribe(pubsub_message) + main.subscribe(pubsub_message, None) out, _ = capsys.readouterr() assert "Hello, world!" in out diff --git a/functions/slack/main_test.py b/functions/slack/main_test.py index f2c88b88444c..4111841a491b 100644 --- a/functions/slack/main_test.py +++ b/functions/slack/main_test.py @@ -48,7 +48,6 @@ def test_verify_signature_token_incorrect(self): request.headers = {'X-Slack-Signature': '12345'} main.verify_signature(request) - @pytest.mark.skip("broken") def test_verify_web_hook_valid_request(self): request = Request() request.headers = { @@ -74,7 +73,6 @@ def test_make_search_request(self): assert 'lion' in message['attachments'][0]['title'].lower() assert message['attachments'][0]['color'] == '#3367d6' - @pytest.mark.skip("broken") def test_kg_search(self): with mock.patch.object(main, 'kgsearch'): entities = main.kgsearch.entities.return_value diff --git a/functions/slack/noxfile_config.py b/functions/slack/noxfile_config.py deleted file mode 100644 index 971f8f0de3df..000000000000 --- a/functions/slack/noxfile_config.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be inported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - 'ignored_versions': ["2.7"], - - # Declare optional test sessions you want to opt-in. Currently we - # have the following optional test sessions: - # 'cloud_run' # Test session for Cloud Run application. - 'opt_in_sessions': [], - - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - 'gcloud_project_env': 'GCLOUD_PROJECT', - # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', - - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - 'envs': { - "SLACK_SECRET": "not sure what value to set", - }, -} diff --git a/testing/secrets.tar.enc b/testing/secrets.tar.enc index 1a749dbfcc0d..b9a1bd4924a6 100644 Binary files a/testing/secrets.tar.enc and b/testing/secrets.tar.enc differ