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

testy zmiany #41

Open
wants to merge 4 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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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

14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.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
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

docker_run:
docker run --name hello-world-printer-dev -p 5000:5000 -d hello-world-printer
2 changes: 1 addition & 1 deletion hello_world/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask
app = Flask(__name__)

import hello_world.views
import hello_world.views
4 changes: 3 additions & 1 deletion hello_world/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from hello_world.formater import SUPPORTED, PLAIN
from flask import request

moje_imie = "Natalia"
moje_imie = "Agata"
msg = "Hello World!"


@app.route('/')
def index():
output = request.args.get('output')
Expand All @@ -14,6 +15,7 @@ def index():
return get_formatted(msg, moje_imie,
output.lower())


@app.route('/outputs')
def supported_output():
return ", ".join(SUPPORTED)
2 changes: 1 addition & 1 deletion test/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)