-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial very basic working Flask app and tests
- Loading branch information
Showing
12 changed files
with
105 additions
and
17 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
"""Machine_Access_Control.""" | ||
"""Decatur Makers Machine Access Control.""" | ||
|
||
from flask import Flask | ||
|
||
|
||
def create_app() -> Flask: | ||
"""Factory to create the app.""" | ||
app: Flask = Flask("dm_mac") | ||
|
||
from dm_mac.views.api import api | ||
|
||
app.register_blueprint(api) | ||
|
||
return app |
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 @@ | ||
"""Init for views (empty).""" |
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,12 @@ | ||
"""API Views.""" | ||
|
||
from flask import Blueprint | ||
|
||
|
||
api: Blueprint = Blueprint("api", __name__, url_prefix="/api") | ||
|
||
|
||
@api.route("/") | ||
def index(): | ||
"""Main API index route - placeholder.""" | ||
return "Hello, World!" |
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 +1 @@ | ||
"""Test suite for the dm_mac package.""" | ||
"""Test suite for the dm_mac package (empty).""" |
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,30 @@ | ||
"""Conftest for dm_mac - fixtures.""" | ||
|
||
import pytest | ||
from flask import Flask | ||
from flask.testing import FlaskClient | ||
|
||
from dm_mac import create_app | ||
|
||
|
||
@pytest.fixture() | ||
def app() -> Flask: | ||
"""Test App fixture - app instance configured for testing.""" | ||
app = create_app() | ||
app.config.update( | ||
{ | ||
"TESTING": True, | ||
} | ||
) | ||
|
||
# other setup can go here | ||
|
||
yield app | ||
|
||
# clean up / reset resources here | ||
|
||
|
||
@pytest.fixture() | ||
def client(app: Flask) -> FlaskClient: | ||
"""Test Client for making requests to test app.""" | ||
return app.test_client() |
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 @@ | ||
"""Test views init (empty).""" |
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,15 @@ | ||
"""Tests for API Views.""" | ||
|
||
from flask.testing import FlaskClient | ||
from werkzeug.test import TestResponse | ||
|
||
|
||
class TestIndex: | ||
"""Tests for API Index view.""" | ||
|
||
def test_index_response(self, client: FlaskClient): | ||
"""Test for API index response.""" | ||
response: TestResponse = client.get("/api/") | ||
assert response.status_code == 200 | ||
assert response.text == "Hello, World!" | ||
assert response.headers["Content-Type"] == "text/html; charset=utf-8" |