Skip to content

Commit 3d8490b

Browse files
committed
Update setup.py
1 parent e739ad3 commit 3d8490b

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

jokeapi/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def build_request(
6161
if id_range:
6262

6363
r = self.http.request('GET', "https://sv443.net/jokeapi/v2/info")
64-
range_limit = json.loads(r.data)["jokes"]["totalCount"]
64+
dict = json.loads(r.data)
65+
range_limit = dict["jokes"]["totalCount"]
6566

6667
if len(id_range) > 2:
6768
raise Exception("id_range must be no longer than 2 items.")

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = README.md

setup.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from distutils.core import setup
2+
setup(
3+
name = 'jokeapi',
4+
packages = ['jokeapi'], # Chose the same as "name"
5+
version = '0.1',
6+
license='GNU General Public License v3 (GPLv3)',
7+
description = 'An API Wrapper for Sv443\'s JokeAPI',
8+
author = 'thenamesweretakenalready',
9+
author_email = 'leet_haker@cyber-wizard.com',
10+
url = 'https://github.com/thenamesweretakenalready/Sv443s-JokeAPI-Python-Wrapper',
11+
download_url = 'https://github.com/user/reponame/archive/v0.1.tar.gz',
12+
keywords = ['api wrapper', 'wrapper', 'api', 'jokes'],
13+
install_requires=[],
14+
classifiers=[
15+
'Development Status :: 3 - Alpha',
16+
'Intended Audience :: Developers',
17+
'Topic :: Software Development :: Build Tools',
18+
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
19+
'Programming Language :: Python :: 3.8',
20+
],
21+
)

version_testing.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from jokeapi import Jokes
2+
3+
j = Jokes()
4+
errors = []
5+
6+
try:
7+
j.get_joke()
8+
except Exception as e:
9+
errors.append({'Error in': 'blank joke get', 'Error':e})
10+
11+
"""Testing for errors in categories"""
12+
try: j.get_joke(category=["programming"])
13+
except Exception as e: errors.append({'Error in': 'category programming','Error':e})
14+
try: j.get_joke(category=["miscellaneous"])
15+
except Exception as e: errors.append({'Error in': 'category miscellaneous','Error':e})
16+
try: j.get_joke(category=["dark"])
17+
except Exception as e: errors.append({'Error in': 'category dark','Error':e})
18+
19+
"""Testing for errors in blacklist"""
20+
try: j.get_joke(blacklist=["nsfw"])
21+
except Exception as e: errors.append({'Error in': 'blacklist nsfw','Error':e})
22+
try: j.get_joke(blacklist=["religious"])
23+
except Exception as e: errors.append({'Error in': 'blacklist religious','Error':e})
24+
try: j.get_joke(blacklist=["political"])
25+
except Exception as e: errors.append({'Error in': 'blacklist political','Error':e})
26+
try: j.get_joke(blacklist=["racist"])
27+
except Exception as e: errors.append({'Error in': 'blacklist political','Error':e})
28+
try: j.get_joke(blacklist=["sexist"])
29+
except Exception as e: errors.append({'Error in': 'blacklist sexist', 'Error':e})
30+
31+
"""Testing for errors in response_format"""
32+
try: j.get_joke(response_format="xml")
33+
except Exception as e: errors.append({'Error in': 'response_format xml','Error':e})
34+
try: j.get_joke(response_format="yaml")
35+
except Exception as e: errors.append({'Error in': 'response_format yaml','Error':e})
36+
37+
"""Testing for errors in type"""
38+
try: j.get_joke(type="single")
39+
except Exception as e: errors.append({'Error in': 'type single','Error':e})
40+
try: j.get_joke(type="twopart")
41+
except Exception as e: errors.append({'Error in': 'type double','Error':e})
42+
43+
"""Testing for errors in search_string"""
44+
try: j.get_joke(search_string="search") #as long as this gets a response, the api wrapper is fine; it probably doesn't exist in a joke
45+
except Exception as e: errors.append({'Error in':'search_string','Error':e})
46+
47+
"""Testing for errors in id_range"""
48+
try: j.get_joke(id_range=[30,151])
49+
except Exception as e: errors.append({'Error in':'id_range','Error':e})
50+
51+
if len(errors):
52+
for e in errors:
53+
print(f"Error in: {e['Error in']}\nError:{e['Error']}")
54+
raise Exception("Errors boii")

0 commit comments

Comments
 (0)