Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
reformatted code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
hatredholder committed Apr 21, 2023
1 parent 5a05f7b commit 2dee33f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 14 deletions.
5 changes: 5 additions & 0 deletions authentication/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SignupForm(FlaskForm):
"""
Form used in the authentication.signup route
"""

username = wtforms.StringField(
"Username: ",
validators=[
Expand Down Expand Up @@ -64,6 +65,7 @@ class GoogleSignupForm(FlaskForm):
"""
Form used in the authentication.signup_from_social_media route
"""

username = wtforms.StringField(
"Username: ",
validators=[
Expand All @@ -79,6 +81,7 @@ class LoginForm(FlaskForm):
"""
Form used in the authentication.login route
"""

username = wtforms.StringField(
"Username: ",
validators=[
Expand All @@ -99,6 +102,7 @@ class PasswordForm(FlaskForm):
"""
Form used in the authentication.password route
"""

current_password = wtforms.PasswordField(
"Current Password: ",
)
Expand Down Expand Up @@ -132,6 +136,7 @@ class ResendForm(FlaskForm):
"""
Form used in the authentication.resend route
"""

username = wtforms.StringField(
"Username",
)
Expand Down
5 changes: 5 additions & 0 deletions pybin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PasteForm(FlaskForm):
"""
Form used in the pybin.home route and pybin.document_clone route
"""

content = wtforms.TextAreaField(
"New Paste",
validators=[
Expand Down Expand Up @@ -59,6 +60,7 @@ class ProfileForm(FlaskForm):
"""
Form used in the pybin.profile route
"""

email = wtforms.EmailField(
"Email Address: ",
validators=[
Expand Down Expand Up @@ -92,6 +94,7 @@ class AvatarForm(FlaskForm):
"""
Form used in the pybin.avatar route
"""

avatar = wtforms.FileField(
"Avatar (jpg/png/gif): ",
)
Expand All @@ -104,6 +107,7 @@ class CommentForm(FlaskForm):
"""
Form used in the pybin.document_view route
"""

content = wtforms.TextAreaField(
"Your Comment",
validators=[
Expand All @@ -127,6 +131,7 @@ class MessageForm(FlaskForm):
"""
Form used in the pybin.message_view route
"""

content = wtforms.TextAreaField(
validators=[
valids.InputRequired(),
Expand Down
11 changes: 8 additions & 3 deletions tests/authentication/functional/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@ def test_auth_google_social_authentication_disabled(client):

@pytest.mark.oauth_configured
def test_callback_redirect_to_error_when_testing_disabled(
app, client, enable_social_authentication,
app,
client,
enable_social_authentication,
):
"""
GIVEN a Flask app, a Flask client and enabled social authentication
Expand All @@ -728,7 +730,8 @@ def test_callback_redirect_to_error_when_testing_disabled(


def test_callback_redirect_to_signup_from_social_media(
client, enable_social_authentication,
client,
enable_social_authentication,
):
"""
GIVEN a Flask client and enabled social authentication
Expand All @@ -746,7 +749,9 @@ def test_callback_redirect_to_signup_from_social_media(


def test_callback_login_already_signed_up_user(
client, create_test_user, enable_social_authentication,
client,
create_test_user,
enable_social_authentication,
):
"""
GIVEN a Flask client, user object, and enabled social authentication
Expand Down
8 changes: 6 additions & 2 deletions tests/authentication/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def test_user_model_get_total_rating_method_is_zero(db, create_test_user):


def test_user_model_get_total_rating_method_with_rated_paste(
db, create_test_user, create_paste_with_rating,
db,
create_test_user,
create_paste_with_rating,
):
"""
GIVEN a User model and Paste(author=create_test_user, rating=1) model
Expand All @@ -39,7 +41,9 @@ def test_user_model_get_total_rating_method_with_rated_paste(


def test_user_model_get_total_rating_method_with_rated_comment(
db, create_test_user, create_comment_with_rating,
db,
create_test_user,
create_comment_with_rating,
):
"""
GIVEN a User model and Comment(author=create_test_user, rating=1) model
Expand Down
21 changes: 15 additions & 6 deletions tests/pybin/functional/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_document_view_route_5_minute_old_comment(
response = authorized_client.get(f"/{create_test_comment.uuid_hash}/")
assert response.status_code == 200

assert b'edit' not in response.data
assert b"edit" not in response.data


def test_document_view_route_incorrect_hash(client):
Expand Down Expand Up @@ -771,7 +771,9 @@ def test_reply_delete_route_delete_reply(


def test_my_pybin_route_template_and_context(
client, captured_templates, create_test_user,
client,
captured_templates,
create_test_user,
):
"""
GIVEN a Flask client, captured_templates function and a user object
Expand Down Expand Up @@ -801,7 +803,9 @@ def test_my_pybin_route_redirect_incorrect_username(client):


def test_my_comments_route_template_and_context(
authorized_client, captured_templates, create_test_user,
authorized_client,
captured_templates,
create_test_user,
):
"""
GIVEN a Flask client, captured_templates function and a user object
Expand Down Expand Up @@ -927,7 +931,10 @@ def test_profile_route_set_incorrect_website_url(authorized_client, create_test_
response = authorized_client.post("/user/profile/", data=data)
assert response.status_code == 200

assert b"Please make sure your website starts with http:// or https://" in response.data
assert (
b"Please make sure your website starts with http:// or https://"
in response.data
)


# Avatar Route
Expand Down Expand Up @@ -967,7 +974,9 @@ def test_avatar_route_update_avatar(authorized_client):
# Search_pastes Route


def test_search_pastes_route_template_and_context(authorized_client, captured_templates):
def test_search_pastes_route_template_and_context(
authorized_client, captured_templates
):
"""
GIVEN an authorized Flask client and captured_templates function
WHEN the "/search/" page is requested
Expand All @@ -991,4 +1000,4 @@ def test_search_pastes_route_with_search_query(authorized_client, create_test_pa
response = authorized_client.get("/search/?q=untitled")
assert response.status_code == 200

assert b'test paste' in response.data
assert b"test paste" in response.data
14 changes: 11 additions & 3 deletions tests/pybin/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,26 @@ def test_reply_model_str_method(create_test_user, create_test_message):
# Message model


def test_message_model_get_last_reply_creation_date_method(create_test_message, create_test_reply):
def test_message_model_get_last_reply_creation_date_method(
create_test_message, create_test_reply
):
"""
GIVEN a test user and a test reply object
WHEN a Message model is created with test user as author
THEN check if string conversion of created model is equal to expected result
"""
assert create_test_message.get_last_reply_creation_date() == create_test_message.created
assert (
create_test_message.get_last_reply_creation_date()
== create_test_message.created
)

create_test_message.replies.append(create_test_reply)
create_test_message.save()

assert create_test_message.get_last_reply_creation_date() != create_test_message.created
assert (
create_test_message.get_last_reply_creation_date()
!= create_test_message.created
)


def test_message_model_str_method(create_test_user):
Expand Down

0 comments on commit 2dee33f

Please sign in to comment.