From 4e5cc46b289907bc703d22a5198f5040dc71a947 Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 03:07:16 +0200 Subject: [PATCH 1/5] Change default beer hour --- beer/beer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beer/beer.py b/beer/beer.py index 2f5d8b9..a7ddf54 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -18,7 +18,7 @@ def index(hours=None, minutes=None): if not hours: hours = 17 if not minutes: - minutes = 0 + minutes = 30 data = render_template('beer.html', hours=hours, minutes=minutes) return data From ad22413145367bfdecc8e6165094ca74c0d6b8b0 Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 03:21:08 +0200 Subject: [PATCH 2/5] [CI] Also fix tests --- staging_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging_tests.sh b/staging_tests.sh index 4501259..65c938e 100644 --- a/staging_tests.sh +++ b/staging_tests.sh @@ -7,7 +7,7 @@ echo "testing URL: ${TEST_URL}" CURL_OPTS='-s' # default -curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 0);' +curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 30);' [ $? -ne 0 ] && echo "Failed with default" && exit 1 # set 1 parameter From 6ae863148f8b4326c31149c7116452cfe2c885ee Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 19:25:29 +0200 Subject: [PATCH 3/5] Fix behaviour when specifying only hour --- beer/beer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beer/beer.py b/beer/beer.py index a7ddf54..4e1ea19 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -17,8 +17,10 @@ def index(hours=None, minutes=None): """ main and only app """ if not hours: hours = 17 - if not minutes: + if hours and not minutes: minutes = 30 + else: + minutes = 0 data = render_template('beer.html', hours=hours, minutes=minutes) return data From ff0bca94213d6f9c1ae6123699e752462b03017b Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 20:54:38 +0200 Subject: [PATCH 4/5] Try to improve tests --- beer/beer.py | 4 ++-- staging_tests.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/beer/beer.py b/beer/beer.py index 4e1ea19..4f0b0ac 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -18,9 +18,9 @@ def index(hours=None, minutes=None): if not hours: hours = 17 if hours and not minutes: - minutes = 30 - else: minutes = 0 + else: + minutes = 30 data = render_template('beer.html', hours=hours, minutes=minutes) return data diff --git a/staging_tests.sh b/staging_tests.sh index 65c938e..e71fcff 100644 --- a/staging_tests.sh +++ b/staging_tests.sh @@ -5,6 +5,18 @@ else fi echo "testing URL: ${TEST_URL}" +while : +do + status_code=$(curl -o /dev/null -s -w '%{http_code}' ${TEST_URL}) + echo "status code: ${status_code}" + [[ ${status_code} -eq 200 ]] && break + [[ ${i} -gt 5 ]] && exit 1 + echo "service not ready or in error" + sleep 5 + i=$(( i+1 )) +done + + CURL_OPTS='-s' # default curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 30);' From 9c3d4252d1d32e3dd675d9e2738081aeaff7aa9a Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 21:47:20 +0200 Subject: [PATCH 5/5] Fix bug --- beer/beer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/beer/beer.py b/beer/beer.py index 4f0b0ac..ae3ddb8 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -15,11 +15,12 @@ app.url_map.strict_slashes = False @app.route('//') def index(hours=None, minutes=None): """ main and only app """ - if not hours: - hours = 17 - if hours and not minutes: - minutes = 0 + + if hours: + if not minutes: + minutes = 0 else: + hours = 17 minutes = 30 data = render_template('beer.html', hours=hours, minutes=minutes)