Skip to content

Commit

Permalink
Add flow v3 parameter (#8)
Browse files Browse the repository at this point in the history
* Add flow v3 parameter

* Linting

* Add unit test
  • Loading branch information
hannahflroiter authored May 21, 2024
1 parent 8650b65 commit cfda9c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ib_cicd/ib_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
23 changes: 22 additions & 1 deletion tests/test_ib_helpers.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down

0 comments on commit cfda9c1

Please sign in to comment.