Skip to content

Commit

Permalink
audio test
Browse files Browse the repository at this point in the history
  • Loading branch information
2captcha committed Oct 6, 2023
1 parent 25369d6 commit 2375ebd
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 2375ebd

Please sign in to comment.