예제 #1
0
def download_telegram_file(telegram_api, file_id, dirpath="/tmp"):
    download_url = telegram_api.getFile(file_id)
    data = make_request(download_url)
    short_name = basename(urlparse(download_url).path)
    filename = join(dirpath, f"{file_id}_{short_name}")
    with open(filename, "wb") as f:
        f.write(data)
    return filename, short_name
예제 #2
0
 def test_hello_world(self):
     response = make_request('http://127.0.0.1:8000/hello')
     self.assertEqual(response, b'world')
예제 #3
0
 def test_server_error(self):
     response = make_request("http://127.0.0.1:8000/error")
     self.assertEqual(response, b"Internal server error")
예제 #4
0
 def test_not_found(self):
     response = make_request("http://127.0.0.1:8000/notfound")
     self.assertEqual(response, b"Not found")
예제 #5
0
 def test_empty_response(self):
     response = make_request("http://127.0.0.1:8000/empty")
     self.assertEqual(response, b"")