Commit dfdd3629 authored by Jorge Garcia-Rivera's avatar Jorge Garcia-Rivera
Browse files

Add unit test

parent 34ab085b
import pytest
import mock
import json
import unittest
import types
from osdu_api.workflow.workflow_client import WorkflowClient
from osdu_api.base_client import BaseClient
from osdu_api.model.http_method import HttpMethod
class TestWorkflowClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_get_bearer_token', return_value="stubbed")
@mock.patch.object(BaseClient, 'make_request', return_value="response")
@mock.patch.object(BaseClient, '_parse_config', return_value="stubbed")
def test_update_workflow_status(self, get_bearer_token_mock, make_request_mock, parse_config_mock):
# Arrange
workflow_client = WorkflowClient()
workflow_client.workflow_url = 'stubbed url'
workflow_client.headers = {}
workflowId = "6893fab0-38eb-4aed-96e9-c667f1e771c8"
workflowStatus = "finished"
expectedDataDictionary = {'WorkflowID': workflowId, 'Status': workflowStatus}
# Act
response = workflow_client.update_workflow_status(workflowId, workflowStatus)
# Assert
make_request_mock.assert_called_with(data=json.dumps(expectedDataDictionary), method=HttpMethod.POST, url='stubbed url')
\ No newline at end of file
......@@ -16,7 +16,7 @@ class WorkflowClient(BaseClient):
# Create a dictionary containing the data for the request
workflow_data_dictionary = {'WorkflowID': workflowId, 'Status': workflowStatus}
# Convert the dictionary into JSON, submit request to API, and return response
# Convert the dictionary into JSON, submit request, and return response
return self.update_workflow_status_from_dict(workflow_data_dictionary)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment