yoda: Pass API query parameters as `params` dict in requests.get().
MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_1.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_1.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=You+will+learn+how+to+speak+like+me+someday.",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "You+will+learn+how+to+speak+like+me+someday."
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=you+still+have+much+to+learn",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "you+still+have+much+to+learn"
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_api_key_error.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_api_key_error.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=You+will+learn+how+to+speak+like+me+someday.",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "You+will+learn+how+to+speak+like+me+someday."
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_invalid_input.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_invalid_input.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=@#$%^&*",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "@#$%^&*"
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=23456",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "23456"
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_service_unavailable_error.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_service_unavailable_error.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=You+will+learn+how+to+speak+like+me+someday.",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "You+will+learn+how+to+speak+like+me+someday."
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/fixtures/test_unknown_error.json
zulip_bots/zulip_bots/bots/yoda/fixtures/test_unknown_error.json
{
"request": {
- "api_url": "https://yoda.p.mashape.com/yoda?sentence=You+will+learn+how+to+speak+like+me+someday.",
+ "api_url": "https://yoda.p.mashape.com/yoda",
+ "params": {
+ "sentence": "You+will+learn+how+to+speak+like+me+someday."
+ },
"headers": {
"X-Mashape-Key": "12345678",
"Accept": "text/plain"

MODIFY
zulip_bots/zulip_bots/bots/yoda/yoda.py
zulip_bots/zulip_bots/bots/yoda/yoda.py
@@ -55,7 +55,8 @@ class YodaSpeakHandler(object):
def send_to_yoda_api(self, sentence: str) -> str:
# function for sending sentence to api
- response = requests.get("https://yoda.p.mashape.com/yoda?sentence=" + sentence,
+ response = requests.get("https://yoda.p.mashape.com/yoda",
+ params=dict(sentence=sentence),
headers={
"X-Mashape-Key": self.api_key,
"Accept": "text/plain"

yoda: Pass API query parameters as `params` dict in requests.get().