|
1 | 1 | from os import getenv |
2 | 2 | from jokeapi import Jokes |
3 | 3 | from dotenv import load_dotenv |
| 4 | +import time |
4 | 5 | load_dotenv() |
5 | 6 |
|
6 | 7 | j = Jokes() |
|
12 | 13 | j.get_joke() |
13 | 14 | except Exception as e: |
14 | 15 | errors.append({'Error in': 'blank joke get', 'Error': e}) |
| 16 | +time.sleep(2) |
15 | 17 |
|
16 | 18 | """Testing auth tokens""" |
17 | 19 | try: |
18 | 20 | j.get_joke(auth_token=token) |
19 | 21 | except Exception as e: |
20 | 22 | auth_token = None |
21 | 23 | errors.append({'Error in': 'auth usage', 'Error': e}) |
| 24 | +time.sleep(2) |
22 | 25 |
|
23 | 26 | """Testing for errors in categories""" |
24 | 27 | try: |
25 | 28 | j.get_joke(category=["programming"], auth_token=token) |
26 | 29 | except Exception as e: |
27 | 30 | errors.append({'Error in': 'category programming', 'Error': e}) |
| 31 | +time.sleep(2) |
28 | 32 | try: |
29 | 33 | j.get_joke(category=["miscellaneous"], auth_token=token) |
30 | 34 | except Exception as e: |
31 | 35 | errors.append({'Error in': 'category miscellaneous', 'Error': e}) |
| 36 | +time.sleep(2) |
32 | 37 | try: |
33 | 38 | j.get_joke(category=["dark"], auth_token=token) |
34 | 39 | except Exception as e: |
35 | 40 | errors.append({'Error in': 'category dark', 'Error': e}) |
| 41 | +time.sleep(2) |
36 | 42 |
|
37 | 43 | """Testing for errors in blacklist""" |
38 | 44 | try: |
39 | 45 | j.get_joke(blacklist=["nsfw"], auth_token=token) |
40 | 46 | except Exception as e: |
41 | 47 | errors.append({'Error in': 'blacklist nsfw', 'Error': e}) |
| 48 | +time.sleep(2) |
42 | 49 | try: |
43 | 50 | j.get_joke(blacklist=["religious"], auth_token=token) |
44 | 51 | except Exception as e: |
45 | 52 | errors.append({'Error in': 'blacklist religious', 'Error': e}) |
| 53 | +time.sleep(2) |
46 | 54 | try: |
47 | 55 | j.get_joke(blacklist=["political"], auth_token=token) |
48 | 56 | except Exception as e: |
49 | 57 | errors.append({'Error in': 'blacklist political', 'Error': e}) |
| 58 | +time.sleep(2) |
50 | 59 | try: |
51 | 60 | j.get_joke(blacklist=["racist"], auth_token=token) |
52 | 61 | except Exception as e: |
53 | 62 | errors.append({'Error in': 'blacklist political', 'Error': e}) |
| 63 | +time.sleep(2) |
54 | 64 | try: |
55 | 65 | j.get_joke(blacklist=["sexist"], auth_token=token) |
56 | 66 | except Exception as e: |
57 | 67 | errors.append({'Error in': 'blacklist sexist', 'Error': e}) |
| 68 | +time.sleep(2) |
58 | 69 |
|
59 | 70 | """Testing for errors in response_format""" |
60 | 71 | try: |
61 | 72 | j.get_joke(response_format="xml", auth_token=token) |
62 | 73 | except Exception as e: |
63 | 74 | errors.append({'Error in': 'response_format xml', 'Error': e}) |
| 75 | +time.sleep(2) |
64 | 76 | try: |
65 | 77 | j.get_joke(response_format="yaml", auth_token=token) |
66 | 78 | except Exception as e: |
67 | 79 | errors.append({'Error in': 'response_format yaml', 'Error': e}) |
| 80 | +time.sleep(2) |
68 | 81 |
|
69 | 82 | """Testing for errors in type""" |
70 | 83 | try: |
71 | 84 | j.get_joke(type="single", auth_token=token) |
72 | 85 | except Exception as e: |
73 | 86 | errors.append({'Error in': 'type single', 'Error': e}) |
| 87 | +time.sleep(2) |
74 | 88 | try: |
75 | 89 | j.get_joke(type="twopart", auth_token=token) |
76 | 90 | except Exception as e: |
77 | 91 | errors.append({'Error in': 'type double', 'Error': e}) |
| 92 | +time.sleep(2) |
78 | 93 |
|
79 | 94 | """Testing for errors in search_string""" |
80 | 95 | try: |
|
83 | 98 | # it probably doesn't exist in a joke. |
84 | 99 | except Exception as e: |
85 | 100 | errors.append({'Error in': 'search_string', 'Error': e}) |
| 101 | +time.sleep(2) |
86 | 102 |
|
87 | 103 | """Testing for errors in id_range""" |
88 | 104 | try: |
89 | 105 | j.get_joke(id_range=[30, 151], auth_token=token) |
90 | 106 | except Exception as e: |
91 | 107 | errors.append({'Error in': 'id_range', 'Error': e}) |
| 108 | +time.sleep(2) |
92 | 109 |
|
93 | 110 | if len(errors): |
94 | 111 | for e in errors: |
|
0 commit comments