From add0ca8ed6903c562e9a0d0353e6bf031d1358c0 Mon Sep 17 00:00:00 2001 From: Syed Bilal Raees <sbilal@nisum.com> Date: Wed, 18 May 2022 18:31:42 +0000 Subject: [PATCH] changes to test,hello and yaml --- .gitlab-ci.yml | 7 +++---- hello.py | 21 ++++++++++++++++----- test.py | 11 +++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 test.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ecb306..ce63a21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,9 @@ stages: - - build + - test test_app: image: python:3.6 - stage: build + stage: test before_script: - python3 -V @@ -12,9 +12,8 @@ test_app: - python3 -m venv venv - python3 -m venv python3-virtualenv - source python3-virtualenv/bin/activate - - pwd script: - pip install Flask - - python hello.py + - python test.py tags: - ci diff --git a/hello.py b/hello.py index 53be245..ee17b13 100644 --- a/hello.py +++ b/hello.py @@ -1,11 +1,22 @@ -import flask - -app = flask.Flask(__name__) -app.config["DEBUG"] = True +#import flask +from flask import Flask, request +#app = flask.Flask(__name__) +#app.config["DEBUG"] = True +app = Flask(__name__) @app.route('/', methods=['GET']) def home(): return "<h1>HelloO DevOps people</h1><p>This site is a prototype API for greeting Nisum DevOps!</p>" -app.run(host='myApp.com', port=5000) +#app.run(host='myApp.com', port=5000) + +@app.route('/') +def calc(): + a = int(request.args.get('a')) + b = int(request.args.get('b')) + + return str(sum(a, b)) + +def sum(a, b): + return a + b diff --git a/test.py b/test.py new file mode 100644 index 0000000..67198cf --- /dev/null +++ b/test.py @@ -0,0 +1,11 @@ +import unittest +from hello import sum + +class Test(unittest.TestCase): + + def test_sum(self): + value = sum(4, 5) + self.assertEqual(value, 9) + +if __name__ == '__main__': + unittest.main() -- 2.18.1