Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ss 1179 add a unit test for the profile changes #241

Merged
merged 33 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d321a3f
Updated info about using Serve for teaching (#194)
akochari Apr 19, 2024
2b5cadc
Revert "Updated info about using Serve for teaching (#194)"
akochari Apr 19, 2024
2d769be
Merge branch 'staging' into main
sandstromviktor May 23, 2024
ab7d54f
Merge branch 'staging'
churnikov Aug 14, 2024
46f589c
Merge branch 'staging'
churnikov Sep 19, 2024
c958069
SS-643-Make-an-option-to-edit-account-details
anondo1969 Oct 7, 2024
7c8099b
SS-643-Make-an-option-to-edit-account-details
anondo1969 Oct 7, 2024
4e3de76
SS-643 extending ProfileForm
anondo1969 Oct 8, 2024
d38f4ce
SS-643 Updated edit HTML form
anondo1969 Oct 10, 2024
d86a443
SS-643 Updated edit HTML form
anondo1969 Oct 10, 2024
32b49eb
SS-643 pre-commit check fixed
anondo1969 Oct 10, 2024
bba6f8b
SS-643 pre-commit with black check
anondo1969 Oct 10, 2024
0048d66
SS-643 pre-commit with black check 2
anondo1969 Oct 10, 2024
cf33450
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 Oct 14, 2024
cded668
fix failing e2e test
akochari Oct 14, 2024
8194013
change the edit profile icon
akochari Oct 14, 2024
a05bf15
uncomment the line I accidentally commented out
akochari Oct 14, 2024
ee23c4e
Update common/views.py
anondo1969 Oct 15, 2024
b3481fd
Update common/forms.py
anondo1969 Oct 15, 2024
6bb12aa
Update common/forms.py
anondo1969 Oct 15, 2024
41b2862
fix super class init.
anondo1969 Oct 15, 2024
491b6f8
changes in view
anondo1969 Oct 15, 2024
da00974
ensure login required in form post method
anondo1969 Oct 15, 2024
f78edf6
Merge branch 'develop' into SS-643-Make-an-option-to-edit-account-det…
anondo1969 Oct 15, 2024
6614a18
creating test profileEdit form
anondo1969 Oct 15, 2024
5dd31cc
creating unit tests for profile edit form
anondo1969 Oct 17, 2024
cb91415
merged from latest develop branch
anondo1969 Oct 22, 2024
85db871
merged from latest develop branch
anondo1969 Oct 22, 2024
caaefc1
rewriting names for testing
anondo1969 Oct 23, 2024
1da935c
rewriting names for testing
anondo1969 Oct 23, 2024
68cb18e
created three unit tests for edit forms
anondo1969 Oct 24, 2024
5756ca8
fixed typo in common/urls.py
anondo1969 Oct 24, 2024
1d609e2
Update common/urls.py
anondo1969 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.contrib.auth.models import User
from django.core import mail
from django.core.exceptions import ValidationError
from django.http import HttpRequest
from django.test import override_settings
from hypothesis import Verbosity, assume, given, settings
from hypothesis import strategies as st
Expand All @@ -16,8 +17,10 @@
DEPARTMENTS,
EMAIL_ALLOW_REGEX,
UNIVERSITIES,
ProfileEditForm,
ProfileForm,
SignUpForm,
UserEditForm,
UserForm,
)
from common.models import EmailVerificationTable, UserProfile
Expand Down Expand Up @@ -235,3 +238,66 @@ def test_fail_validation_other_email_affiliation_selected(form):
"Please select 'Other' in affiliation or use your Swedish university researcher email."
]
} == form.user.errors


@pytest.mark.parametrize(
"first_name, last_name",
[
("abc", "xyz"),
("122124", "57457458"),
("/&)(&(/))", "@#€%€%&"),
],
)
def test_pass_validation_user_edit_form(first_name, last_name):
request = HttpRequest()
request.POST = {
"first_name": first_name,
"last_name": last_name,
}
form = UserEditForm(request.POST, instance=UserProfile(), initial={"email": "a@uu.se"})
assert form.is_valid()


@pytest.mark.parametrize(
"first_name, last_name",
[
("", "xyz"),
("abc", ""),
("", ""),
(" ", " "),
(None, ""),
("", None),
(None, None),
],
)
def test_fail_validation_user_edit_form(first_name, last_name):
request = HttpRequest()
request.POST = {"first_name": first_name, "last_name": last_name}
form = UserEditForm(request.POST, instance=UserProfile(), initial={"email": "a@uu.se"})
assert not form.is_valid()


@pytest.mark.parametrize(
"department",
[
("abc"),
("122445"),
("@#%&&"),
(""),
(" "),
(None),
],
)
def test_pass_validation_profile_edit_form(department):
request = HttpRequest()
request.POST = {
"department": department,
}
form = ProfileEditForm(
request.POST,
instance=UserProfile(),
initial={
"affiliation": "uu",
},
)
assert form.is_valid()
1 change: 1 addition & 0 deletions common/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required
from django.urls import include, path

from . import views
Expand Down
Loading