Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions oss/andong_edu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
class AndongEdu:
def hello(self, name):
return "Hello, {name}!".format(name=name)

def ping(self):
return "pong"

def add(self, num1, num2):
return num1 * num2
6 changes: 5 additions & 1 deletion oss/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
def hello_world(name):
return edu.hello(name)

@app.route('/ping')
def ping():
return edu.ping()

@app.route('/add/<num1>/<num2>')
def add(num1, num2):
raise NotImplementedError("Not Implemented")
return str(edu.add(int(num1), int(num2)))

@app.route('/minus/<num1>/<num2>')
def minus(num1, num2):
Expand Down
26 changes: 25 additions & 1 deletion oss/tests/test_andong_edu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@


class TestAndongEdu(TestCase):
def test_hello_world(self):
def test_hello_world_success(self):
test_edu = AndongEdu()
assert "Hello, test!" == test_edu.hello("test")

def test_hello_world_failure(self):
test_edu = AndongEdu()
assert "Hello, test123!" != test_edu.hello("test")

def test_ping_success(self):
test_edu = AndongEdu()
assert "pong" == test_edu.ping()

def test_ping_failure(self):
test_edu = AndongEdu()
assert "pong1" != test_edu.ping()

def test_add_success1(self):
test_edu = AndongEdu()
assert 4 == test_edu.add(2,2)

def test_add_success2(self):
test_edu = AndongEdu()
assert 2 == test_edu.add(0,2)

def test_add_success3(self):
test_edu = AndongEdu()
assert 3 == test_edu.add(1,2)