Closed jenniferjiangkells closed 1 day ago
Hi @jenniferjiangkells. I would like to work on this issue. Can you assign it to me
implemented the follwoing function, can you please give me feedback for it?
import unittest
from typing import Callable, Dict, Optional, Union
from decorators import api, APIMethod
class TestAPIDecorator(unittest.TestCase):
def test_api_decorator_basic_functionality(self):
@api
def sample_api_function():
return "Hello, API!"
# Test if function has 'is_service_route'
self.assertTrue(hasattr(sample_api_function, 'is_service_route'))
# Test if attribute 'is_service_route' is True
self.assertTrue(sample_api_function.is_service_route)
# Test the return value of function
self.assertEqual(sample_api_function(), "Hello, API!")
# Test if the function is wrapped in APIMethod
wrapped_function = APIMethod(sample_api_function)
self.assertIsInstance(wrapped_function, APIMethod)
self.assertEqual(wrapped_function.func(), "Hello, API!")
if __name__ == "__main__":
unittest.main()
@jenniferjiangkells should I just directly push the above function?
@rajatkriplani This is great but can you please make sure to create a fork and open a Pull Request for this - you can follow the steps in our contributing guideline 🙂 Also mind that we use Pytest for the project.
@rajatkriplani This is great but can you please make sure to create a fork and open a Pull Request for this - you can follow the steps in our contributing guideline 🙂 Also mind that we use Pytest for the project.
on it!
Hey, I'd like to work on this if it is still open. Do let me know if this issue has not been resolved :)
@rajatkriplani are you still working on this?
I assume no one was working on this . I have added the necessary tests . @jenniferjiangkells Please review the PR and let me know if any changes are required !
Description
We need to implement unit tests for the API decorator in the
test_decorators.py
file. Currently, there are no tests specifically covering the functionality of this decorator.Context
The API decorator is used to mark and configure API endpoints. Testing this decorator is important to ensure it behaves correctly under various scenarios and integrates properly with the rest of the system.
The
api
decorator does two things that the new test function needs to cover:is_service_route
APIMethod
decorators.py
apimethod.py
Possible Implementation
Add a new test function in
test_decorators.py
, for example: