Skip to content
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
2 changes: 1 addition & 1 deletion eva_sub_cli/call_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _send_event(self, event_type, **kwargs):
def send_start(self):
self._send_event(EVENT_START)

def send_validation_completed(self, validation_result):
def send_validation_completed(self, validation_result: dict):
self._send_event(EVENT_VALIDATION_COMPLETED, validation_result=validation_result)

def send_end(self):
Expand Down
16 changes: 15 additions & 1 deletion tests/test_call_home.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import json
import os
import shutil
import time
import uuid
from unittest import TestCase
from unittest.mock import patch

import jsonschema

from ebi_eva_common_pyutils.config import Configuration, WritableConfig
from requests.exceptions import ConnectionError, Timeout

from eva_sub_cli import SUB_CLI_CONFIG_FILE, ROOT_DIR
from eva_sub_cli.call_home import _get_or_create_deployment_id, _get_or_create_run_id, \
CallHomeClient, EVENT_START, EVENT_FAILURE, EVENT_END
from tests.test_report import common_validation_results


class TestDeploymentId(TestCase):
Expand Down Expand Up @@ -163,12 +167,22 @@ def test_generic_exception_swallowed(self, mock_post):

@patch('eva_sub_cli.call_home.requests.post')
def test_send_all_event_types(self, mock_post):
schema_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'..', 'eva_sub_cli', 'etc', 'call_home_payload_schema.json')
with open(schema_path) as f:
schema = json.load(f)

client = self._create_client()
client.send_start()
client.send_validation_completed('PASS')
client.send_validation_completed(common_validation_results)
client.send_end()
self.assertEqual(mock_post.call_count, 3)

for call in mock_post.call_args_list:
payload = call.kwargs['json']
jsonschema.validate(instance=payload, schema=schema)


@patch('eva_sub_cli.call_home.requests.post')
def test_send_failure_event(self, mock_post):
client = self._create_client()
Expand Down