-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit df4713e
Showing
11 changed files
with
103 additions
and
0 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,4 @@ | ||
FLASK_APP=strong_but_simple_passwords | ||
FLASK_ENV=development | ||
|
||
SBSP_SECRET_KEY=something-secret |
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,5 @@ | ||
venv/ | ||
htmlcov/ | ||
.coverage | ||
__pycache__/ | ||
*.egg-info |
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 @@ | ||
graft strong_but_simple_passwords/templates |
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,9 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="strong-but-simple-passwords", | ||
version="0.1.0", | ||
packages=find_packages(), | ||
include_package_data=True, | ||
install_requires=["flask"], | ||
) |
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,16 @@ | ||
from flask import Flask | ||
from .config import get_config_from_env_vars | ||
from . import views | ||
|
||
|
||
def create_app(config=None): | ||
app = Flask(__name__) | ||
|
||
if config is None: | ||
config = get_config_from_env_vars() | ||
|
||
app.config.from_object(config) | ||
|
||
app.add_url_rule("/", "index", view_func=views.index) | ||
|
||
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,8 @@ | ||
import os | ||
|
||
|
||
def get_config_from_env_vars(): | ||
class Config: | ||
SECRET_KEY = os.environ["SBSP_SECRET_KEY"] | ||
|
||
return Config |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>First test!</title> | ||
</head> | ||
|
||
<body> | ||
This is a template! | ||
</body> | ||
|
||
</html> |
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,5 @@ | ||
from flask import render_template | ||
|
||
|
||
def index(): | ||
return render_template("index.html") |
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,17 @@ | ||
import pytest | ||
from strong_but_simple_passwords import create_app | ||
|
||
|
||
class TestConfig: | ||
SECRET_KEY = "something-secret" | ||
TESTING = True | ||
|
||
|
||
@pytest.fixture | ||
def app(): | ||
return create_app(TestConfig) | ||
|
||
|
||
@pytest.fixture | ||
def client(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,22 @@ | ||
from strong_but_simple_passwords import create_app | ||
import os | ||
|
||
|
||
def test_custom_config(): | ||
class Config: | ||
SECRET_KEY = "custom-secret-key" | ||
TESTING = True | ||
|
||
app = create_app(Config) | ||
|
||
assert app.config["SECRET_KEY"] == "custom-secret-key" | ||
assert app.testing | ||
|
||
|
||
def test_config_from_env_vars(): | ||
os.environ["SBSP_SECRET_KEY"] = "secret-key-from-env-var" | ||
|
||
app = create_app() | ||
|
||
assert app.config["SECRET_KEY"] == "secret-key-from-env-var" | ||
assert not app.testing |
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,3 @@ | ||
def test_index_http_ok(client): | ||
response = client.get("/") | ||
assert response.status_code == 200 |