ceph / teuthology-api

A REST API to execute teuthology commands.
MIT License
2 stars 10 forks source link

Auth service tests #31

Open dikwickley opened 1 year ago

dikwickley commented 1 year ago

This PR aims to add tests for the auth service. WIP for #5

dikwickley commented 1 year ago

@VallariAg I have separated out the service layer in /login route. Now the GH login part can be mocked easily by replacing the AuthServiceGH with AuthServiceMock during testing. We can use this to replace it: https://fastapi.tiangolo.com/advanced/testing-dependencies/

If this looks good I can proceed with writing the tests.

dikwickley commented 1 year ago

hi @VallariAg can you review this?

VallariAg commented 1 year ago

@dikwickley please refer my comments above

dikwickley commented 1 year ago

@VallariAg i can't see your comments

VallariAg commented 1 year ago

@dikwickley oh, that's weird! I added a comment to that thread, I wonder if you are able to see that?

But here's what my comments said for AuthServiceMock class:

This class is used only for testing so it should be defined somewhere under /tests directory You can probably create similar dir structure in /tests as it is in /src. Also to mock functions, you can look into unittest.mock functions and pytest fixtures https://docs.python.org/3/library/unittest.mock.html

edit: my bad, I didn't realise that if I don't "submit" a review then the comments would only be visible to me!