Skip to content

Commit

Permalink
Api decorator test (#94)
Browse files Browse the repository at this point in the history
* Overflow and Type Errors added to concept.py . Required tests for quantity class added in tests.

* minor issues fixed

* code formatted

* python-version file removed

* Removed TypeError for None and updated tests

* test_cdaannotator updated

* cdaannotator updated with find various sections using codes functionality

* timeout member added to ehrclient class

* docstring updated!

* updated docstring

* test for api decorator added !

---------

Co-authored-by: Adam Kells <[email protected]>
  • Loading branch information
Vortex-21 and adamkells authored Oct 30, 2024
1 parent 329f686 commit aa6ee27
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from healthchain.apimethod import APIMethod
import pytest

from healthchain.clients import ehr
from healthchain.decorators import find_attributes_of_type, assign_to_attribute
from healthchain.decorators import api, find_attributes_of_type, assign_to_attribute

from .conftest import MockDataGenerator

Expand Down Expand Up @@ -64,3 +65,18 @@ def test_multiple_calls(self, function, mock_cds):


# TODO: add test for api decorator
def test_api_decorator():
@api
def test_function():
return "test"

# test if the function is correctly wrapped in the APImethod instance.
result = test_function()
assert isinstance(result, APIMethod)
assert result.func() == "test"

# test if function has "is_service_route"
assert hasattr(test_function, "is_service_route")

# test if the "is_service_route" member is set to True.
assert test_function.is_service_route is True

0 comments on commit aa6ee27

Please sign in to comment.