Skip to content

Commit 80cf4b9

Browse files
committed
add tests, run linter
1 parent 9dad80c commit 80cf4b9

File tree

6 files changed

+148
-153
lines changed

6 files changed

+148
-153
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.0] - June , 2020
6+
⚠ Major Update (Breaking Changes)
7+
8+
### Added
9+
- Add API key authorizations
10+
- Custom API URL support
11+
12+
### Changed
13+
- Due to Judge0 API going [freemium](https://github.com/judge0/api/issues/171), the default API URL, [https://api.judge0.com] is no longer available. To use the API signup for a plan on [RapidAPI](https://rapidapi.com/hermanzdosilovic/api/judge0/pricing)
14+
15+
516
## [0.8] - May 27, 2020
617

718
### Fix

coderunner/coderunner.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@
5252
"max_file_size": "1024",
5353
}
5454

55-
HEADERS = {
56-
"x-rapidapi-host": "judge0.p.rapidapi.com",
57-
"useQueryString": True
58-
}
55+
HEADERS = {"x-rapidapi-host": "judge0.p.rapidapi.com", "useQueryString": True}
5956

60-
API_URL = "https://judge0.p.rapidapi.com/"
61-
#API_URL = "https://judge0.p.rapidapi.com/submissions/"
6257
FIELDS = "?fields=stdout,memory,time,status,stderr,exit_code,created_at"
6358

6459

@@ -68,8 +63,9 @@ class ValueTooLargeError(Exception):
6863

6964
class InvalidURL(Exception):
7065
"""Raise when api_url is invalid"""
66+
7167
def __init__(self, message):
72-
super.__init__(message)
68+
super().__init__(message)
7369

7470

7571
class code:
@@ -147,7 +143,9 @@ def __readStatus(self, token: str):
147143
Check Submission Status
148144
"""
149145
while True:
150-
req = urllib.request.Request(f'{self.API_URL}submissions/{token["token"]}{FIELDS}', headers=HEADERS)
146+
req = urllib.request.Request(
147+
f'{self.API_URL}submissions/{token["token"]}{FIELDS}', headers=HEADERS
148+
)
151149
with urllib.request.urlopen(req) as response:
152150
req = response.read()
153151

@@ -173,7 +171,9 @@ def __submit(self):
173171
api_params["source_code"] = self.source
174172

175173
post_data = urllib.parse.urlencode(api_params).encode("ascii")
176-
req = urllib.request.Request(f'{API_URL}submissions/', post_data, headers=HEADERS)
174+
req = urllib.request.Request(
175+
f"{self.API_URL}submissions/", post_data, headers=HEADERS
176+
)
177177
with urllib.request.urlopen(req) as response:
178178
req = response.read()
179179
token = json.loads(req.decode("utf-8"))
@@ -185,7 +185,7 @@ def api(self, key: str, url: str = None):
185185
HEADERS["x-rapidapi-key"] = key
186186
self.API_KEY = key
187187
if url is None:
188-
self.API_URL = API_URL
188+
self.API_URL = "https://judge0.p.rapidapi.com/"
189189
else:
190190
user_api_url = urllib.parse.urlparse(url)
191191
if user_api_url.scheme and user_api_url.netloc:

demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
from dotenv import load_dotenv
6+
67
load_dotenv()
78

89
source_code = "testfiles/" + "test_python_input.py"
@@ -14,6 +15,8 @@
1415
API_KEY = os.environ["API_KEY"]
1516

1617
r = coderunner.code(source_code, language, output, Input)
18+
19+
# Necessary step to initialize API keys & URL
1720
r.api(key=API_KEY)
1821

1922
# r2 = coderunner.code("print(\"yo\")", "Python3", "YO", path=False)
@@ -23,6 +26,7 @@
2326

2427
print("Run r :")
2528
print("Status : " + r.getStatus())
29+
print("Output : " + r.getOutput())
2630

2731
# r2.run()
2832

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
setuptools.setup(
77
name="coderunner",
8-
version="0.8",
8+
version="1.0",
99
license="MIT",
1010
author="Bhupesh Varshney",
1111
author_email="[email protected]",
1212
description="A judge for your programs, run and test your programs through Python",
13-
keywords='judge0 coderunner judge0api codeclassroom ',
13+
keywords="judge0 coderunner judge0api codeclassroom ",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",
1616
url="https://codeclassroom.github.io/CodeRunner/",
@@ -19,7 +19,7 @@
1919
"Source Code": "https://github.com/codeclassroom/CodeRunner",
2020
"Funding": "https://www.patreon.com/bePatron?u=18082750",
2121
"Say Thanks!": "https://github.com/codeclassroom/CodeRunner/issues/new?assignees=&labels=&template=---say-thank-you.md&title=",
22-
'Tracker': "https://github.com/codeclassroom/CodeRunner/issues",
22+
"Tracker": "https://github.com/codeclassroom/CodeRunner/issues",
2323
},
2424
packages=setuptools.find_packages(),
2525
classifiers=[
@@ -36,5 +36,5 @@
3636
"Topic :: Software Development :: Libraries :: Python Modules",
3737
"Operating System :: OS Independent",
3838
],
39-
python_requires='>=3.6',
39+
python_requires=">=3.6",
4040
)

testfiles/test_python_input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
n = int(input())
22
temp = n
33
rev = 0
4-
while(n > 0):
4+
while n > 0:
55
dig = n % 10
66
rev = rev * 10 + dig
77
n = n // 10
8-
if(temp == rev):
8+
if temp == rev:
99
print("The number is a palindrome!")
1010
else:
1111
print("The number isn't a palindrome!")

0 commit comments

Comments
 (0)