-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Create profile test #90
Open
MartinAlbertGbur
wants to merge
10
commits into
master
Choose a base branch
from
user-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5f7320d
pridavanie seminara a prikladu
MartinAlbertGbur a141e6d
serializery na vytvorenie semestra + testy
MartinAlbertGbur e82ea59
oprava
MartinAlbertGbur 39696af
dalsi pokus na test
MartinAlbertGbur 86456a5
Uprava semester serializer
kovacspe 782f1c2
testy na update usera/profilu
MartinAlbertGbur 62c8d6f
dokoncenie testov, no stale to este nefunguje
MartinAlbertGbur 9adf384
oprava - profiledata
MartinAlbertGbur feef30d
zmena self.profiledata
MartinAlbertGbur cecd637
Merged with master
kovacspe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ class User(AbstractBaseUser, PermissionsMixin): | |
default=False, | ||
help_text='Umožňuje prihlásiť sa do administrácie.',) | ||
is_active = models.BooleanField( | ||
verbose_name='aktnívny', | ||
verbose_name='aktívny', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch 🚀 |
||
default=True, | ||
help_text='Označuje, či je používateľ aktívny. ' | ||
'Používa sa namiesto mazania účtov.',) | ||
|
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,95 @@ | ||
from django.contrib.auth.models import User | ||
from rest_framework.test import APITestCase | ||
from user.models import User | ||
from django.test import Client | ||
from competition.forms import ProfileUpdateForm | ||
from user.forms import UserChangeForm, NameUpdateForm | ||
from personal.models import County, District, School, Profile | ||
from personal.serializers import ProfileSerializer | ||
|
||
class UpdateUserTest(APITestCase): | ||
def test_user_change_form(self): | ||
form = UserChangeForm(data = { | ||
'email': '[email protected]', | ||
'password': 'Aa123456' | ||
}) | ||
self.assertTrue(form.is_valid()) | ||
|
||
def test_wrong_email(self): | ||
form = UserChangeForm(data = { | ||
'email': '123', | ||
'password': 'Aa123456' | ||
}) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_name_change_form(self): | ||
form = NameUpdateForm(data = { | ||
'first_name': 'Jožko', | ||
'last_name': 'Mrkvička' | ||
}) | ||
self.assertTrue(form.is_valid()) | ||
|
||
def test_profile_update_form(self): | ||
form = ProfileUpdateForm(data = { | ||
'first_name':'Účastník', | ||
'last_name':'Matikovský', | ||
'user' : { | ||
'email':'[email protected]', 'password':'1234abcd' | ||
}, | ||
'nickname' : 'ucastnik', | ||
'school' : { | ||
'name' : 'Gymnázium', | ||
'district' : { | ||
'name' : 'Košice I', | ||
'county': {'name' : 'Košický kraj'} | ||
}, | ||
'street' : 'Poštová 9', | ||
'city': 'Košice', | ||
'zip_code' : '04001' | ||
}, 'year_of_graduation': 2025, | ||
'phone' : '+421901234567', | ||
'parent_phone' : '+421987654321', | ||
'gdpr' : True | ||
}) | ||
|
||
self.assertTrue(form.is_valid()) | ||
|
||
def setUp(self): | ||
self.client = Client() | ||
user = User.objects.create(email="[email protected]", password="1234abcd") | ||
|
||
county = County.objects.create(name="Košický kraj") | ||
district = District.objects.create(name="Košice I", county=county) | ||
school = School.objects.create(name='Gymnázium', district=district, street='Poštová 9', city='Košice', zip_code='04001') | ||
|
||
self.profile = Profile.objects.create( | ||
first_name='Účastník', last_name='Matikovský', user = user, | ||
nickname = 'ucastnik', school = school, year_of_graduation = 2025, | ||
phone = '+421901234567', parent_phone = '+421987654321', gdpr = True | ||
) | ||
|
||
#self.superuser = User.objects.create_superuser('veduci','1234abcd') | ||
#self.veduci_log_in = {'username':'veduci', 'password':'1234abcd'} | ||
#self.client.post('/user/login/',self.veduci_log_in) | ||
|
||
self.profiledata = ProfileSerializer(self.profile) | ||
self.userdata = { | ||
'first_name': 'Účastník', | ||
'last_name': 'Matikovský' | ||
} | ||
|
||
self.profiledata.update({'first_name': 'Meno', 'last_name': 'Priezvisko'}) | ||
self.userdata.update({'first_name': 'Meno', 'last_name': 'Priezvisko'}) | ||
|
||
self.data = { | ||
'user' : self.userdata, | ||
'profile' : self.profiledata | ||
} | ||
|
||
self.log_in = {'nickname':'ucastnik', 'password':'1234abcd'} | ||
|
||
def test_can_update_profile(self): | ||
response_log_in = self.client.post('/user/login/',self.log_in) | ||
self.assertEqual(response_log_in.status_code,200) | ||
response = self.client.post('/user/profile/update/', self.data) | ||
self.assertEqual(response.status_code, 200) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➕