Skip to content

Commit db8bc1b

Browse files
author
thenamesweretakenalready
committed
💚 Use user_agent in all test cases
1 parent 6d9cf74 commit db8bc1b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/test_main.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,96 +18,96 @@ async def test_main():
1818
token = getenv("token")
1919

2020
try:
21-
await j.get_joke()
21+
await j.get_joke(user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
2222
except Exception as e:
2323
errors.append({"Error in": "blank joke get", "Error": e})
2424

2525
"""Testing auth tokens"""
2626
try:
27-
await j.get_joke(auth_token=token)
27+
await j.get_joke(auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
2828
except Exception as e:
2929
auth_token = None
3030
errors.append({"Error in": "auth usage", "Error": e})
3131

3232
"""Testing for errors in categories"""
3333
try:
34-
await j.get_joke(category=["programming"], auth_token=token)
34+
await j.get_joke(category=["programming"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
3535
except Exception as e:
3636
errors.append({"Error in": "category programming", "Error": e})
3737
try:
38-
await j.get_joke(category=["misc"], auth_token=token)
38+
await j.get_joke(category=["misc"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
3939
except Exception as e:
4040
errors.append({"Error in": "category miscellaneous", "Error": e})
4141
try:
42-
await j.get_joke(category=["dark"], auth_token=token)
42+
await j.get_joke(category=["dark"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
4343
except Exception as e:
4444
errors.append({"Error in": "category dark", "Error": e})
4545

4646
"""Testing for errors in blacklist"""
4747
try:
48-
await j.get_joke(blacklist=["nsfw"], auth_token=token)
48+
await j.get_joke(blacklist=["nsfw"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
4949
except Exception as e:
5050
errors.append({"Error in": "blacklist nsfw", "Error": e})
5151

5252
try:
53-
await j.get_joke(blacklist=["religious"], auth_token=token)
53+
await j.get_joke(blacklist=["religious"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
5454
except Exception as e:
5555
errors.append({"Error in": "blacklist religious", "Error": e})
5656

5757
try:
58-
await j.get_joke(blacklist=["political"], auth_token=token)
58+
await j.get_joke(blacklist=["political"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
5959
except Exception as e:
6060
errors.append({"Error in": "blacklist political", "Error": e})
6161

6262
try:
63-
await j.get_joke(blacklist=["racist"], auth_token=token)
63+
await j.get_joke(blacklist=["racist"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
6464
except Exception as e:
6565
errors.append({"Error in": "blacklist political", "Error": e})
6666

6767
try:
68-
await j.get_joke(blacklist=["sexist"], auth_token=token)
68+
await j.get_joke(blacklist=["sexist"], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
6969
except Exception as e:
7070
errors.append({"Error in": "blacklist sexist", "Error": e})
7171

7272
"""Testing for errors in response_format"""
7373
try:
74-
await j.get_joke(response_format="xml", auth_token=token)
74+
await j.get_joke(response_format="xml", auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
7575
except Exception as e:
7676
errors.append({"Error in": "response_format xml", "Error": e})
7777

7878
try:
79-
await j.get_joke(response_format="yaml", auth_token=token)
79+
await j.get_joke(response_format="yaml", auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
8080
except Exception as e:
8181
errors.append({"Error in": "response_format yaml", "Error": e})
8282

8383
"""Testing for errors in type"""
8484
try:
85-
await j.get_joke(joke_type="single", auth_token=token)
85+
await j.get_joke(joke_type="single", auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
8686
except Exception as e:
8787
errors.append({"Error in": "type single", "Error": e})
8888

8989
try:
90-
await j.get_joke(joke_type="twopart", auth_token=token)
90+
await j.get_joke(joke_type="twopart", auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
9191
except Exception as e:
9292
errors.append({"Error in": "type double", "Error": e})
9393

9494
"""Testing for errors in search_string"""
9595
try:
96-
await j.get_joke(search_string="search", auth_token=token)
96+
await j.get_joke(search_string="search", auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
9797
# as long as this gets a response, the api wrapper is fine;
9898
# it probably doesn't exist in a joke.
9999
except Exception as e:
100100
errors.append({"Error in": "search_string", "Error": e})
101101

102102
"""Testing for errors in id_range"""
103103
try:
104-
await j.get_joke(id_range=[30, 151], auth_token=token)
104+
await j.get_joke(id_range=[30, 151], auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
105105
except Exception as e:
106106
errors.append({"Error in": "id_range", "Error": e})
107107

108108
"""Testing for errors in safe_mode"""
109109
try:
110-
await j.get_joke(safe_mode=True, auth_token=token)
110+
await j.get_joke(safe_mode=True, auth_token=token, user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/91.0.4472.164 Safari/537.36")
111111
except Exception as e:
112112
errors.append({"Error in": "safe_mode", "Error": e})
113113

0 commit comments

Comments
 (0)