Skip to content

Commit

Permalink
Merge pull request #18 from novonordisk-research/release
Browse files Browse the repository at this point in the history
Fix audit trail
  • Loading branch information
SRFU-NN authored Aug 10, 2023
2 parents 13d148c + a1cc800 commit fdb21de
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ Then manually run the
[release GitHub action](https://github.com/novonordisk-research/OptiHPLCHandler/actions/workflows/release.yml)
by clicking `Run workflow`. Select what type of release it is by typing in `--patch`, `--minor`, or `--major` in `The type of release to perform`, and then click `Run workflow`.

Fetch the new branch `release`. Make sure there isn't a `dist` folder in
your project folder (or delete it), and run the commands
Fetch the new branch `release`. Run the commands

```
rm -r -fo dist
py -m build
py -m twine upload dist/*
```
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "Opti_HPLC_Handler"
version = "0.2.6"
version = "0.2.7"
description = "Simplified proxy API for interacting with the Waters Empower Web API."
readme = "README.md"
requires-python = ">=3.8"
Expand Down Expand Up @@ -85,7 +85,7 @@ pythonpath = [
]

[tool.bumpver]
current_version = "0.2.6"
current_version = "0.2.7"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "bump version {old_version} -> {new_version}"
tag_message = "{new_version}"
Expand Down
2 changes: 1 addition & 1 deletion src/OptiHPLCHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from .empower_api_core import EmpowerConnection
from .empower_handler import EmpowerHandler

__version__ = "0.2.6"
__version__ = "0.2.7"

__all__ = ["DataField", "EmpowerConnection", "EmpowerHandler", "HPLCSetup", "Sample"]
6 changes: 5 additions & 1 deletion src/OptiHPLCHandler/empower_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ def PostExperiment(
endpoint = "project/methods/sample-set-method"
if audit_trail_message:
logger.debug("Adding audit trail message to endpoint")
endpoint += f"&auditTrailComment={audit_trail_message}"
endpoint += f"?auditTrailComment={audit_trail_message}"
response = self.connection.post(endpoint=endpoint, body=sampleset_object)
if response.status_code != 201:
if response.status_code == 404:
raise ValueError(
"Could not post sample set method. Resource not found."
)
raise ValueError(
f"Could not post sample set method. Response: {response.text}"
)
Expand Down
27 changes: 26 additions & 1 deletion tests/test_proxy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_empower_handler_post_sample_list(self, mock_requests):
assert "test_sampleset_name" == mock_requests.method_calls[0][2]["json"]["name"]
# Testing that the name is correct in the request
assert (
"auditTrailComment=test_audit_trail_message"
"?auditTrailComment=test_audit_trail_message"
in mock_requests.method_calls[0][1][0]
)
# Testing that the audit trail message is correct
Expand Down Expand Up @@ -135,6 +135,31 @@ def test_empower_handler_post_sample_list(self, mock_requests):
assert all([dict_type == "Enumerator" for dict_type in dict_type_list])
# Testing that all dictionary values are strings

@patch("OptiHPLCHandler.empower_api_core.requests")
def test_empower_handler_post_sample_list_error(self, mock_requests):
mock_response = MagicMock()
mock_response.json.return_value = {"results": "mock_results"}
mock_response.status_code = 404
mock_requests.post.return_value = mock_response
with self.assertRaises(ValueError) as context:
self.handler.PostExperiment(
sample_set_method_name="test_sampleset_name",
sample_list=[],
plate_list=[],
audit_trail_message="test_audit_trail_message",
)
assert "Resource not found" in context.exception.args[0]
mock_response.status_code = 400
mock_response.text = "mock_error_message"
with self.assertRaises(ValueError) as context:
self.handler.PostExperiment(
sample_set_method_name="test_sampleset_name",
sample_list=[],
plate_list=[],
audit_trail_message="test_audit_trail_message",
)
assert "Response: mock_error_message" in context.exception.args[0]

def test_empower_handler_add_method(self):
with self.assertRaises(NotImplementedError):
self.handler.AddMethod(
Expand Down

0 comments on commit fdb21de

Please sign in to comment.