diff --git a/tests/test_audio.py b/tests/test_audio.py new file mode 100644 index 0000000..32f0696 --- /dev/null +++ b/tests/test_audio.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 + +import unittest +from base64 import b64encode + + +file = '../examples/audio/example.mp3' +url = 'https://github.com/2captcha/2captcha-python/raw/polukhin_audio/examples/audio/example.mp3' + + +with open(file, "rb") as media: + b64 = b64encode(media.read()).decode('utf-8') + +try: + from .abstract import AbstractTest + + file = file[3:] + +except ImportError: + from abstract import AbstractTest + + + + +class AudioTest(AbstractTest): + + def test_base64(self): + + params = { + 'lang' : 'en', + } + + sends = { + 'method': 'audio', + 'lang' : 'en', + 'body' : b64, + } + + return self.send_return(sends, self.solver.audio, file=b64 **params) + + def test_file(self): + + params = { + 'lang' : 'en', + } + + sends = { + 'method': 'audio', + 'lang' : 'en', + 'body' : b64, + } + + return self.send_return(sends, self.solver.audio, file=file, **params) + + + def test_url(self): + + params = { + 'lang' : 'en', + } + + sends = { + 'method': 'audio', + 'lang' : 'en', + 'body' : b64, + } + + return self.send_return(sends, self.solver.audio, file=url **params) + + + def test_not_found(self): + + return self.invalid_file(self.solver.audio) + + + +if __name__ == '__main__': + + unittest.main() +