diff --git a/ib_cicd/ib_helpers.py b/ib_cicd/ib_helpers.py index a24e5ca..d74988f 100644 --- a/ib_cicd/ib_helpers.py +++ b/ib_cicd/ib_helpers.py @@ -224,7 +224,10 @@ def compile_solution(ib_host, api_token, solution_path, relative_flow_path): solution_path, *relative_flow_path.split("/")[:-1] ), "predefined_binary_path": os.path.join(solution_path, bin_path), - "settings": {"flow_file": relative_flow_path.split("/")[-1]}, + "settings": { + "flow_file": relative_flow_path.split("/")[-1], + "is_flow_v3": True, + }, } ) resp = requests.post( diff --git a/tests/test_ib_helpers.py b/tests/test_ib_helpers.py index 05cb0d0..15f4061 100644 --- a/tests/test_ib_helpers.py +++ b/tests/test_ib_helpers.py @@ -1,8 +1,9 @@ """Collection of unit tests for IB Helpers""" +import json from unittest import mock from requests.models import Response -from ib_cicd.ib_helpers import upload_file +from ib_cicd.ib_helpers import upload_file, compile_solution from tests.fixtures import ( ib_host_url, ib_api_token, @@ -11,6 +12,26 @@ ) +@mock.patch("ib_cicd.ib_helpers.requests") +def test_compile_solution(mock_requests, ib_host_url, ib_api_token): + # Arrange + mocked_response = mock.Mock(spec=Response) + mocked_response.status_code = 200 + mocked_response.content = json.dumps({"status": "OK"}) + mock_requests.post.return_value = mocked_response + + solution_path = "Test Space/Test Subspace/fs/Instabase Drive/My Solution" + relative_flow_path = "Path to flow/flow.ibflow" + compile_solution(ib_host_url, ib_api_token, solution_path, relative_flow_path) + + mock_requests.post.assert_called_with( + "https://instbase-fake-testing-url.com/api/v1/flow_binary/compile/Test%20Space/Test%20Subspace/fs/Instabase%20Drive/My%20Solution", + headers={"Authorization": "Bearer fake-testing-token"}, + data='{"binary_type": "Single Flow", "flow_project_root": "Test Space/Test Subspace/fs/Instabase Drive/My Solution/Path to flow", "predefined_binary_path": "Test Space/Test Subspace/fs/Instabase Drive/My Solution/Path to flow/flow.ibflowbin", "settings": {"flow_file": "flow.ibflow", "is_flow_v3": true}}', + verify=False, + ) + + @mock.patch("ib_cicd.ib_helpers.requests") def test_upload_file(mock_requests, ib_host_url, ib_api_token): # Arrange