Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Conversation

ramiboutas
Copy link
Contributor

It would be wise to use the python-deepl library: https://github.com/DeepLcom/deepl-python

It would be wise to use the python-deepl library: https://github.com/DeepLcom/deepl-python
@zerolab zerolab mentioned this pull request Aug 29, 2022
@zerolab
Copy link
Collaborator

zerolab commented Aug 29, 2022

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)
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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

@zerolab
Copy link
Collaborator

zerolab commented Sep 12, 2022

Tidied up and merged in 605c124.

Thanks @ramiboutas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants