-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39-set_start_method-to-spawn-for-windows (#46)
* set_start_method to "spawn" for windows Fixes #39 * fixes for mongodb * Jm-updates-tests-mongo (#45) * fix typo * adds db * swap destination for cruise * move tests to their own file * fix typo * updates pages for cruise/cruise-id
- Loading branch information
1 parent
2888f62
commit c42d321
Showing
7 changed files
with
191 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import pytest | ||
|
||
from flaskapp import models | ||
|
||
|
||
@pytest.fixture | ||
def client(app_with_db): | ||
return app_with_db.test_client() | ||
|
||
|
||
def test_index(client): | ||
response = client.get("/") | ||
|
||
assert response.status_code == 200 | ||
assert b"Welcome to ReleCloud" in response.data | ||
|
||
|
||
def test_about(client): | ||
response = client.get("/about") | ||
|
||
assert response.status_code == 200 | ||
assert b"About ReleCloud" in response.data | ||
|
||
|
||
def test_destinations(client): | ||
response = client.get("/destinations") | ||
|
||
assert response.status_code == 200 | ||
assert b"Destinations" in response.data | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_destination_detail(client): | ||
sun = models.Destination.objects(name="The Sun").first() | ||
response = client.get(f"/destination/{sun.id}") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_cruise_detail(client): | ||
sun_and_earth = models.Cruise.objects(name="The Sun and Earth").first() | ||
response = client.get(f"/cruise/{sun_and_earth.id}") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun and Earth" in response.data | ||
|
||
|
||
def test_info_request(client): | ||
response = client.get("/info_request") | ||
|
||
assert response.status_code == 200 | ||
assert b"Request Info" in response.data | ||
|
||
|
||
def test_create_info_request(client): | ||
sun_and_earth = models.Cruise.objects(name="The Sun and Earth").first() | ||
response = client.post( | ||
"/info_request", | ||
data={ | ||
"name": "Amanda Valdez", | ||
"email": "[email protected]", | ||
"notes": "Please send me more information.", | ||
"cruise_id": f"{sun_and_earth.id}", | ||
}, | ||
) | ||
|
||
assert response.status_code == 302 | ||
assert ( | ||
response.headers["Location"] | ||
== "/info_request?message=Thank+you,+Amanda+Valdez!+We+will+email+you+when+we+have+more+information!" | ||
) | ||
|
||
info_request = models.InfoRequest.objects(name="Amanda Valdez").first() | ||
assert info_request.name == "Amanda Valdez" | ||
assert info_request.email == "[email protected]" | ||
assert info_request.notes == "Please send me more information." | ||
assert info_request.cruise == sun_and_earth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import pytest | ||
from sqlalchemy import select | ||
|
||
from flaskapp import db, models | ||
|
||
|
||
@pytest.fixture | ||
def client(app_with_db): | ||
return app_with_db.test_client() | ||
|
||
|
||
def test_index(client): | ||
response = client.get("/") | ||
|
||
assert response.status_code == 200 | ||
assert b"Welcome to ReleCloud" in response.data | ||
|
||
|
||
def test_about(client): | ||
response = client.get("/about") | ||
|
||
assert response.status_code == 200 | ||
assert b"About ReleCloud" in response.data | ||
|
||
|
||
def test_destinations(client): | ||
response = client.get("/destinations") | ||
|
||
assert response.status_code == 200 | ||
assert b"Destinations" in response.data | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_destination_detail(app_with_db, client): | ||
with app_with_db.app_context(): | ||
sun = db.session.query(models.Destination).filter(models.Destination.name == "The Sun").first() | ||
response = client.get(f"/destination/{sun.id}") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_cruise_detail(app_with_db, client): | ||
with app_with_db.app_context(): | ||
sun_and_earth = db.session.query(models.Cruise).where(models.Cruise.name == "The Sun and Earth").first() | ||
response = client.get(f"/cruise/{sun_and_earth.id}") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun and Earth" in response.data | ||
|
||
|
||
def test_info_request(client): | ||
response = client.get("/info_request") | ||
|
||
assert response.status_code == 200 | ||
assert b"Request Info" in response.data | ||
|
||
|
||
def test_create_info_request(app_with_db, client): | ||
with app_with_db.app_context(): | ||
sun_and_earth = db.session.query(models.Cruise).where(models.Cruise.name == "The Sun and Earth").first() | ||
response = client.post( | ||
"/info_request", | ||
data={ | ||
"name": "Amanda Valdez", | ||
"email": "[email protected]", | ||
"notes": "Please send me more information.", | ||
"cruise_id": f"{sun_and_earth.id}", | ||
}, | ||
) | ||
|
||
assert response.status_code == 302 | ||
assert ( | ||
response.headers["Location"] | ||
== "/info_request?message=Thank+you,+Amanda+Valdez!+We+will+email+you+when+we+have+more+information!" | ||
) | ||
|
||
info_request = db.session.query(models.InfoRequest).order_by(models.InfoRequest.id.desc()).first() | ||
assert info_request.name == "Amanda Valdez" | ||
assert info_request.email == "[email protected]" | ||
assert info_request.notes == "Please send me more information." | ||
assert info_request.cruise_id == sun_and_earth.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 7 additions & 76 deletions
83
{{cookiecutter.__src_folder_name}}/src/flask/tests/local/test_pages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,7 @@ | ||
import pytest | ||
|
||
from flaskapp import db, models | ||
|
||
|
||
@pytest.fixture | ||
def client(app_with_db): | ||
return app_with_db.test_client() | ||
|
||
|
||
def test_index(client): | ||
response = client.get("/") | ||
|
||
assert response.status_code == 200 | ||
assert b"Welcome to ReleCloud" in response.data | ||
|
||
|
||
def test_about(client): | ||
response = client.get("/about") | ||
|
||
assert response.status_code == 200 | ||
assert b"About ReleCloud" in response.data | ||
|
||
|
||
def test_destinations(client): | ||
response = client.get("/destinations") | ||
|
||
assert response.status_code == 200 | ||
assert b"Destinations" in response.data | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_destination_detail(client): | ||
response = client.get("/destination/1") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun" in response.data | ||
|
||
|
||
def test_cruise_detail(client): | ||
response = client.get("/cruise/1") | ||
|
||
assert response.status_code == 200 | ||
assert b"The Sun and Earth" in response.data | ||
|
||
|
||
def test_info_request(client): | ||
response = client.get("/info_request") | ||
|
||
assert response.status_code == 200 | ||
assert b"Request Info" in response.data | ||
|
||
|
||
def test_create_info_request(app_with_db, client): | ||
response = client.post( | ||
"/info_request", | ||
data={ | ||
"name": "Amanda Valdez", | ||
"email": "[email protected]", | ||
"notes": "Please send me more information.", | ||
"cruise_id": "12345", | ||
}, | ||
) | ||
|
||
assert response.status_code == 302 | ||
assert ( | ||
response.headers["Location"] | ||
== "/info_request?message=Thank+you,+Amanda+Valdez!+We+will+email+you+when+we+have+more+information!" | ||
) | ||
|
||
with app_with_db.app_context(): | ||
info_request = db.session.query(models.InfoRequest).order_by(models.InfoRequest.id.desc()).first() | ||
assert info_request.name == "Amanda Valdez" | ||
assert info_request.email == "[email protected]" | ||
assert info_request.notes == "Please send me more information." | ||
assert info_request.cruise_id == 12345 | ||
{# Template found in "templates" directory at root #} | ||
{% if 'postgres' in cookiecutter.db_resource %} | ||
{% include "flask_test_pages_postgres.py" %} | ||
{% endif %} | ||
{% if 'mongo' in cookiecutter.db_resource %} | ||
{% include "flask_test_pages_mongodb.py" %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters