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

functions: fix slack + pubsub tests #3808

Merged
merged 12 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion functions/pubsub/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def publish(request):
'data': {'message': message},
})
message_bytes = message_json.encode('utf-8')
print(message_bytes)

# Publishes a message
try:
Expand Down
16 changes: 6 additions & 10 deletions functions/pubsub/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,36 @@
import os

from mock import MagicMock
import pytest

import main


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)
tmatsuo marked this conversation as resolved.
Show resolved Hide resolved

out, _ = capsys.readouterr()
assert "Hello, world!" in out
2 changes: 0 additions & 2 deletions functions/slack/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down
44 changes: 0 additions & 44 deletions functions/slack/noxfile_config.py

This file was deleted.

Binary file modified testing/secrets.tar.enc
Binary file not shown.