-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeepL offers a free API now #604
Conversation
It would be wise to use the python-deepl library: https://github.com/DeepLcom/deepl-python
Note: alternative to #505 @ramiboutas any chance you could add a small test for this |
self.assertEqual(auth_key_is_free_account(self.free_auth_key), True) | ||
|
||
def test_api_paid(self): | ||
self.assertEqual(auth_key_is_free_account(self.paid_auth_key), False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a start, but I was thinking checking that DeepLTranslator.translate
uses the correct URL based on the key, since that is what we want to test first and foremost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That it is what I also wanted but I dont know how to do that; my apologies. I will learn more about writting tests and come back to the issue again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look for mocking (e.g. https://bhch.github.io/posts/2017/09/python-testing-how-to-mock-requests-during-tests/)
alternatively, move the logic to return a URL to a method in DeepLTranslator
(e.g. get_api_endpoint
), and use that in requests.post
. Then you can test with override_settings
to change the key
in your test you could call DeepLTranslator({}).get_api_endpoint()
and check its value
Tidied up and merged in 605c124. Thanks @ramiboutas |
It would be wise to use the python-deepl library: https://github.com/DeepLcom/deepl-python