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
def test_hello_world(self): response = make_request('http://127.0.0.1:8000/hello') self.assertEqual(response, b'world')
def test_server_error(self): response = make_request("http://127.0.0.1:8000/error") self.assertEqual(response, b"Internal server error")
def test_not_found(self): response = make_request("http://127.0.0.1:8000/notfound") self.assertEqual(response, b"Not found")
def test_empty_response(self): response = make_request("http://127.0.0.1:8000/empty") self.assertEqual(response, b"")