Skip to content

Commit

Permalink
100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-peters committed Mar 27, 2021
1 parent 104e712 commit 7f02f84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
8 changes: 2 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class TestConfig:


@pytest.fixture
def app():
return create_app(TestConfig)


@pytest.fixture
def client(app):
def client():
app = create_app(TestConfig)
return app.test_client()
21 changes: 21 additions & 0 deletions tests/test_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
from strong_but_simple_passwords.core import sentences


def test_index_http_ok(client):
response = client.get("/")
assert response.status_code == 200


def test_empty_post(client):
response = client.post("/")

is_sentence_in = [cur_sentence in str(response.data) for cur_sentence in sentences]

assert response.status_code == 200
assert any(is_sentence_in)


def test_strong_password(client):
payload = {"input_sentence": "A very long input sentence for a strong password"}
response = client.post("/", data=payload)

assert response.status_code == 200
assert b"Congratulations!" in response.data
assert b"centuries" in response.data
4 changes: 2 additions & 2 deletions tests/test_static_files.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def test_css_http_ok(app, client):
def test_css_http_ok(client):
response = client.get("/static/css/styles.css")
assert response.status_code == 200

response = client.get("/static/css/normalize.css")
assert response.status_code == 200


def test_img_http_ok(app, client):
def test_img_http_ok(client):
response = client.get("/static/img/GitHub-Mark-64px.png")
assert response.status_code == 200

0 comments on commit 7f02f84

Please sign in to comment.