From 5dc32be79a18d8975e20f95cf93bd25f81573763 Mon Sep 17 00:00:00 2001 From: agadkaminska <120246524+AgaDKaminskA@users.noreply.github.com> Date: Sat, 1 Apr 2023 10:42:40 +0000 Subject: [PATCH 1/4] testy zmiany --- hello_world/views.py | 2 +- test/test_views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hello_world/views.py b/hello_world/views.py index 81d6d7b39..f8435a831 100644 --- a/hello_world/views.py +++ b/hello_world/views.py @@ -3,7 +3,7 @@ from hello_world.formater import SUPPORTED, PLAIN from flask import request -moje_imie = "Natalia" +moje_imie = "AGATA" msg = "Hello World!" @app.route('/') diff --git a/test/test_views.py b/test/test_views.py index b99e757fd..66de2ec4c 100644 --- a/test/test_views.py +++ b/test/test_views.py @@ -15,4 +15,4 @@ def test_outputs(self): def test_msg_with_output(self): rv = self.app.get('/?output=json') - self.assertEqual(b'{ "imie":"Natalia", "mgs":Hello World!"}', rv.data) + self.assertEqual(b'{ "imie":"AGATA", "mgs":Hello World!"}', rv.data) From 688b08fdd9c048d78a3dfbe97ab4aa2f1f6313b9 Mon Sep 17 00:00:00 2001 From: agadkaminska <120246524+AgaDKaminskA@users.noreply.github.com> Date: Sat, 1 Apr 2023 12:57:18 +0000 Subject: [PATCH 2/4] nowe zmiany --- Makefile | 15 +++++++++++++++ hello_world/__init__.py | 2 +- hello_world/views.py | 4 +++- test/test_views.py | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..55b67428d --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +.PHONY: deps test + +deps: + pip install -r requirements.txt; \ + pip install -r test_requirements.txt + +run: + python main.py + +lint: + flake8 hello_world test + +test: + PYTHONPATH=. py.test + diff --git a/hello_world/__init__.py b/hello_world/__init__.py index fde7ecee2..a923de589 100644 --- a/hello_world/__init__.py +++ b/hello_world/__init__.py @@ -1,4 +1,4 @@ from flask import Flask app = Flask(__name__) -import hello_world.views \ No newline at end of file +# import hello_world.views diff --git a/hello_world/views.py b/hello_world/views.py index f8435a831..6b8772355 100644 --- a/hello_world/views.py +++ b/hello_world/views.py @@ -3,9 +3,10 @@ from hello_world.formater import SUPPORTED, PLAIN from flask import request -moje_imie = "AGATA" +moje_imie = "Agata" msg = "Hello World!" + @app.route('/') def index(): output = request.args.get('output') @@ -14,6 +15,7 @@ def index(): return get_formatted(msg, moje_imie, output.lower()) + @app.route('/outputs') def supported_output(): return ", ".join(SUPPORTED) diff --git a/test/test_views.py b/test/test_views.py index 66de2ec4c..2422a5bbd 100644 --- a/test/test_views.py +++ b/test/test_views.py @@ -15,4 +15,4 @@ def test_outputs(self): def test_msg_with_output(self): rv = self.app.get('/?output=json') - self.assertEqual(b'{ "imie":"AGATA", "mgs":Hello World!"}', rv.data) + self.assertEqual(b'{ "imie":"Agata", "mgs":Hello World!"}', rv.data) From 7120c278142794be0b40860cea6d131ff91244ff Mon Sep 17 00:00:00 2001 From: agadkaminska <120246524+AgaDKaminskA@users.noreply.github.com> Date: Sun, 2 Apr 2023 12:13:15 +0000 Subject: [PATCH 3/4] docker --- Dockerfile | 14 ++++++++++++++ Makefile | 17 ++++++++++++++++- hello_world/__init__.py | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..f3745465d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3 + +ARG APP_DIR=/usr/src/hello_world_printer + +WORKDIR /tmp +ADD requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt + +RUN mkdir -p $APP_DIR +ADD hello_world/ $APP_DIR/hello_world/ +ADD main.py $APP_DIR + +CMD PYTHONPATH=$PYTHONPATH:/usr/src/hello_world_printer \ + FLASK_APP=hello_world flask run --host=0.0.0.0 diff --git a/Makefile b/Makefile index 55b67428d..0243580ae 100644 --- a/Makefile +++ b/Makefile @@ -12,4 +12,19 @@ lint: test: PYTHONPATH=. py.test - + PYTHONPATH=. py.test --verbose -s + +activate: + source .venv/bin/action + +curl: + curl 127.0.0.1:5000/ + +docker_build: + docker build -t hello-world-printer . + +test_smoke: + curl --fail 127.0.0.1:5000 + +test_smoke: + curl -s -o /dev/null -w "%{http_code}" --fail 127.0.0.1:5000 diff --git a/hello_world/__init__.py b/hello_world/__init__.py index a923de589..03370a306 100644 --- a/hello_world/__init__.py +++ b/hello_world/__init__.py @@ -1,4 +1,4 @@ from flask import Flask app = Flask(__name__) -# import hello_world.views +import hello_world.views From 7ba0265757211b15aa2910ea9245a95dab31dbc8 Mon Sep 17 00:00:00 2001 From: agadkaminska <120246524+AgaDKaminskA@users.noreply.github.com> Date: Sun, 2 Apr 2023 12:50:07 +0000 Subject: [PATCH 4/4] n --- .github/workflows/ci.yaml | 19 +++++++++++++++++++ Makefile | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..b38aac54d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,19 @@ +on: [push] + +jobs: + build_and_test: + runs-on: ubuntu-latest + + steps: + # pobierz kod + - uses: actions/checkout@v3 + # moja aplikacja jest w Pythonie + - name: Set up Python 3 + uses: actions/setup-python@v3 + # instalacja wymaganych bibliotek + - name: Install deps + run: make deps + # testy!!!!! + - name: Tests + run: make test + diff --git a/Makefile b/Makefile index 0243580ae..edb3fb8a4 100644 --- a/Makefile +++ b/Makefile @@ -28,3 +28,6 @@ test_smoke: test_smoke: curl -s -o /dev/null -w "%{http_code}" --fail 127.0.0.1:5000 + +docker_run: + docker run --name hello-world-printer-dev -p 5000:5000 -d hello-world-printer