From cf4775252d2955ed86fc893af0c12224090ece63 Mon Sep 17 00:00:00 2001 From: charsyam Date: Wed, 6 Nov 2019 12:14:49 +0900 Subject: [PATCH 1/2] [#7] ping ping --- oss/andong_edu.py | 3 +++ oss/main.py | 4 ++++ oss/tests/test_andong_edu.py | 14 +++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/oss/andong_edu.py b/oss/andong_edu.py index 925ddff..7c92dc1 100644 --- a/oss/andong_edu.py +++ b/oss/andong_edu.py @@ -1,3 +1,6 @@ class AndongEdu: def hello(self, name): return "Hello, {name}!".format(name=name) + + def ping(self): + return "pong" diff --git a/oss/main.py b/oss/main.py index 22d5ce8..0a317f2 100644 --- a/oss/main.py +++ b/oss/main.py @@ -10,6 +10,10 @@ def hello_world(name): return edu.hello(name) +@app.route('/ping') +def ping(): + return edu.ping() + @app.route('/add//') def add(num1, num2): raise NotImplementedError("Not Implemented") diff --git a/oss/tests/test_andong_edu.py b/oss/tests/test_andong_edu.py index ec2c883..4259e99 100644 --- a/oss/tests/test_andong_edu.py +++ b/oss/tests/test_andong_edu.py @@ -4,6 +4,18 @@ 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() From aa3aae02be302b52230ff6a8ccef460501a86ba4 Mon Sep 17 00:00:00 2001 From: charsyam Date: Wed, 6 Nov 2019 17:37:29 +0900 Subject: [PATCH 2/2] add test --- oss/andong_edu.py | 3 +++ oss/main.py | 2 +- oss/tests/test_andong_edu.py | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/oss/andong_edu.py b/oss/andong_edu.py index 7c92dc1..725f815 100644 --- a/oss/andong_edu.py +++ b/oss/andong_edu.py @@ -4,3 +4,6 @@ def hello(self, name): def ping(self): return "pong" + + def add(self, num1, num2): + return num1 * num2 diff --git a/oss/main.py b/oss/main.py index 0a317f2..fbb2df0 100644 --- a/oss/main.py +++ b/oss/main.py @@ -16,7 +16,7 @@ def ping(): @app.route('/add//') def add(num1, num2): - raise NotImplementedError("Not Implemented") + return str(edu.add(int(num1), int(num2))) @app.route('/minus//') def minus(num1, num2): diff --git a/oss/tests/test_andong_edu.py b/oss/tests/test_andong_edu.py index 4259e99..fd6bfe3 100644 --- a/oss/tests/test_andong_edu.py +++ b/oss/tests/test_andong_edu.py @@ -19,3 +19,15 @@ def test_ping_success(self): 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)