Skip to content

Commit

Permalink
Merge pull request #5 from questionlp/develop
Browse files Browse the repository at this point in the history
Update Flask and Werkzeug Versions, Update Routes and Test Scripts
  • Loading branch information
questionlp authored Aug 3, 2022
2 parents 3ae7a82 + a51f848 commit 3eec1e7
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 84 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
# Changes

## 2.1.0

### Component Changes

- Upgrade Flask to 2.2.0
- Upgrade Werkzeug from 2.1.2 to 2.2.1
- Upgrade Plotly JS from 2.11.1 to 2.12.1

### Application Changes

- Update guests, hosts, locations, panelists, scorekeepers and shows routes and redirects so that canonical routes now have a trailing slash and requests made without a trailing slash will get redirected

### Development Changes

- Upgrade pytest from 6.2.5 to 7.1.2
- Add type hinting to pytest scripts
- Upgrade Black from 22.1.0 to 22.6.0
- Change Black `target-version` to remove `py36` and `py37`, and add `py310`

## 2.0.1

### Application Changes

- Fixed typo in `500` error page

## 2.0.0

### Component Updates
### Component Changes

- Replace (lib)wwdtm 1.2.x with wwdtm 2.0.5 (or higher)
- Upgrade Flask from 2.0.1 to 2.1.1
Expand Down
6 changes: 4 additions & 2 deletions app/main/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ def favicon():


@blueprint.route("/panelist")
@blueprint.route("/panelists")
def panelist():
"""Redirect: /panelist to /panelists"""
"""Redirect: /panelist and /panelists to /panelists/"""
return redirect_url(url_for("panelists.index"))


@blueprint.route("/show")
@blueprint.route("/shows")
def show():
"""Redirect: /show to /shows"""
"""Redirect: /show and /shows to /shows/"""
return redirect_url(url_for("shows.index"))


Expand Down
20 changes: 10 additions & 10 deletions app/static/js/plotly.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/templates/errors/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

{% block content %}
<h1>Oops...</h1>
<p>Something went terrible wrong!</p>

<p>Something went terribly wrong!</p>
{% endblock %}
2 changes: 1 addition & 1 deletion app/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# graphs.wwdt.me is released under the terms of the Apache License 2.0
"""Errors module for Wait Wait Graphs Site"""

APP_VERSION = "2.0.0"
APP_VERSION = "2.1.0"
1 change: 1 addition & 0 deletions config.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"compress": false,
"charset": "utf8mb4",
"collation": "utf8mb4_unicode_ci",
"time_zone": "UTC"
},

"settings": {
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.black]
required-version = "22.1.0"
target-version = ["py36", "py37", "py38", "py39"]
required-version = "22.6.0"
target-version = ["py38", "py39", "py310"]
7 changes: 4 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
flake8==4.0.1
pycodestyle==2.8.0
pytest==6.2.5
black==22.1.0
pytest==7.1.2
black==22.6.0

Flask==2.1.1
Flask==2.2.0
Werkzeug==2.2.1
pytz==2022.1
gunicorn==20.1.0

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Flask==2.1.1
Flask==2.2.0
Werkzeug==2.2.1
pytz==2022.1
gunicorn==20.1.0

wwdtm>=2.0.5
wwdtm==2.0.5
2 changes: 1 addition & 1 deletion runner.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# Shell script used to start up Flask for local development and testing
export FLASK_APP=app
export FLASK_ENV=development
export FLASK_DEBUG=1
export FLASK_RUN_PORT=8000
. venv/bin/activate
flask run
32 changes: 22 additions & 10 deletions tests/test_main_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,55 @@
# Copyright (c) 2018-2022 Linh Pham
# graphs.wwdt.me is released under the terms of the Apache License 2.0
"""Testing Main Redirects Module and Blueprint Views"""
from flask.testing import FlaskClient
from werkzeug.test import TestResponse


def test_favicon(client):
def test_favicon(client: FlaskClient) -> None:
"""Testing main_redirects.favicon"""
response = client.get("/favicon.ico")
response: TestResponse = client.get("/favicon.ico")
assert response.status_code == 302
assert response.location
assert "/static/favicon.ico" in response.location


def test_guest(client):
def test_guest(client: FlaskClient) -> None:
"""Testing main_redirects.panelist"""
response = client.get("/panelist")
response: TestResponse = client.get("/panelist")
assert response.status_code == 302
assert response.location
assert "/panelists" in response.location

response: TestResponse = client.get("/panelists")
assert response.status_code == 302
assert response.location
assert "/panelists" in response.location


def test_help(client):
def test_help(client: FlaskClient) -> None:
"""Testing main_redirects.show"""
response = client.get("/show")
response: TestResponse = client.get("/show")
assert response.status_code == 302
assert response.location
assert "/shows" in response.location

response: TestResponse = client.get("/shows")
assert response.status_code == 302
assert response.location
assert "/shows" in response.location


def test_show_show_counts_by_year(client):
def test_show_show_counts_by_year(client: FlaskClient) -> None:
"""Testing main_redirects.show_show_counts_by_year"""
response = client.get("/show/show-counts-by-year")
response: TestResponse = client.get("/show/show-counts-by-year")
assert response.status_code == 302
assert response.location
assert "/shows/counts-by-year" in response.location


def test_show_counts_by_year(client):
def test_show_counts_by_year(client: FlaskClient) -> None:
"""Testing main_redirects.shows_show_counts_by_year"""
response = client.get("/shows/show-counts-by-year")
response: TestResponse = client.get("/shows/show-counts-by-year")
assert response.status_code == 302
assert response.location
assert "/shows/counts-by-year" in response.location
10 changes: 6 additions & 4 deletions tests/test_main_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
# Copyright (c) 2018-2022 Linh Pham
# graphs.wwdt.me is released under the terms of the Apache License 2.0
"""Testing Main Routes Module and Blueprint Views"""
from flask.testing import FlaskClient
from werkzeug.test import TestResponse


def test_index(client):
def test_index(client: FlaskClient) -> None:
"""Testing main.index"""
response = client.get("/")
response: TestResponse = client.get("/")
assert response.status_code == 200
assert b"Wait Wait Don't Tell Me! Graphs" in response.data
assert b"/panelists/" in response.data
assert b"/shows/" in response.data


def robots_txt(client):
def robots_txt(client: FlaskClient) -> None:
"""Testing main.robots_txt"""
response = client.get("/robots.txt")
response: TestResponse = client.get("/robots.txt")
assert response.status_code == 200
assert b"Sitemap:" in response.data
assert b"User-agent:" in response.data
39 changes: 22 additions & 17 deletions tests/test_panelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,79 @@
# Copyright (c) 2018-2022 Linh Pham
# graphs.wwdt.me is released under the terms of the Apache License 2.0
"""Testing Panelists Module and Blueprint Views"""

from flask.testing import FlaskClient
import pytest
from werkzeug.test import TestResponse


def test_index(client):
def test_index(client: FlaskClient) -> None:
"""Testing main.index"""
response = client.get("/panelists")
response: TestResponse = client.get("/panelists/")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Aggregate Scores" in response.data
assert b"Score Breakdown" in response.data


def test_aggregate_scores(client):
def test_aggregate_scores(client: FlaskClient) -> None:
"""Testing main.aggregate_scores"""
response = client.get("/panelists/aggregate-scores")
response: TestResponse = client.get("/panelists/aggregate-scores")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Aggregate Scores" in response.data
assert b"Aggregate Scores Breakdown" in response.data


def test_appearances_by_year(client):
def test_appearances_by_year(client: FlaskClient) -> None:
"""Testing main.appearances_by_year"""
response = client.get("/panelists/appearances-by-year")
response: TestResponse = client.get("/panelists/appearances-by-year")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Appearances by Year" in response.data


@pytest.mark.parametrize("panelist_slug", ["adam-felber", "faith-salie"])
def test_appearances_by_year_details(client, panelist_slug: str):
def test_appearances_by_year_details(client: FlaskClient, panelist_slug: str) -> None:
"""Testing main.appearances_by_year"""
response = client.get(f"/panelists/appearances-by-year/{panelist_slug}")
response: TestResponse = client.get(
f"/panelists/appearances-by-year/{panelist_slug}"
)
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Appearances by Year for" in response.data


def test_score_breakdown(client):
def test_score_breakdown(client: FlaskClient) -> None:
"""Testing main.score_breakdown"""
response = client.get("/panelists/score-breakdown")
response: TestResponse = client.get("/panelists/score-breakdown")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Score Breakdown" in response.data


@pytest.mark.parametrize("panelist_slug", ["adam-felber", "faith-salie"])
def test_score_breakdown_details(client, panelist_slug: str):
def test_score_breakdown_details(client: FlaskClient, panelist_slug: str) -> None:
"""Testing main.score_breakdown"""
response = client.get(f"/panelists/score-breakdown/{panelist_slug}")
response: TestResponse = client.get(f"/panelists/score-breakdown/{panelist_slug}")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Score Breakdown for" in response.data


def test_scores_by_appearance(client):
def test_scores_by_appearance(client: FlaskClient) -> None:
"""Testing main.scores_by_appearance"""
response = client.get("/panelists/scores-by-appearance")
response: TestResponse = client.get("/panelists/scores-by-appearance")
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Scores by Appearance" in response.data


@pytest.mark.parametrize("panelist_slug", ["adam-felber", "faith-salie"])
def test_scores_by_appearance_details(client, panelist_slug: str):
def test_scores_by_appearance_details(client: FlaskClient, panelist_slug: str) -> None:
"""Testing main.scores_by_appearance"""
response = client.get(f"/panelists/scores-by-appearance/{panelist_slug}")
response: TestResponse = client.get(
f"/panelists/scores-by-appearance/{panelist_slug}"
)
assert response.status_code == 200
assert b"Panelists" in response.data
assert b"Scores by Appearance for" in response.data
Loading

0 comments on commit 3eec1e7

Please sign in to comment.