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

Feature/profile add is interested in mobility #32

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions account/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Meta:
"postal_code",
"optional_postal_code",
"is_filled_for_fun",
"is_interested_in_mobility",
"result_can_be_used",
"gender",
]
Expand Down
17 changes: 17 additions & 0 deletions account/migrations/0012_profile_is_interested_in_mobility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.3 on 2024-03-06 07:44

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("account", "0011_profile_gender"),
]

operations = [
migrations.AddField(
model_name="profile",
name="is_interested_in_mobility",
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Profile(models.Model):
postal_code = models.CharField(max_length=10, null=True)
optional_postal_code = models.CharField(max_length=10, null=True)
is_filled_for_fun = models.BooleanField(default=False)
is_interested_in_mobility = models.BooleanField(default=False)
result_can_be_used = models.BooleanField(default=True)
gender = models.CharField(
max_length=2, choices=GENDER_OPTIONS, null=True, blank=True
Expand Down
41 changes: 41 additions & 0 deletions account/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,47 @@ def test_profile_created(api_client):
assert user.profile.postal_code is None


@pytest.mark.django_db
def test_profile_put(api_client_authenticated, users, profiles):
user = users.get(username="test1")
url = reverse("account:profiles-detail", args=[user.id])
assert user.profile.is_interested_in_mobility is False
assert user.profile.is_filled_for_fun is False
assert user.profile.gender is None
assert user.profile.postal_code is None
assert user.profile.optional_postal_code is None
assert user.profile.result_can_be_used is True
data = {
"postal_code": "20210",
"optional_postal_code": "20220",
"is_interested_in_mobility": True,
"gender": "F",
"is_filled_for_fun": True,
"result_can_be_used": False,
}
response = api_client_authenticated.put(url, data)
assert response.status_code == 200
user.refresh_from_db()
assert user.profile.is_interested_in_mobility is True
assert user.profile.is_filled_for_fun is True
assert user.profile.gender == "F"
assert user.profile.postal_code == "20210"
assert user.profile.optional_postal_code == "20220"
assert user.profile.result_can_be_used is False


@pytest.mark.django_db
def test_profile_patch_is_interested_in_mobility(
api_client_authenticated, users, profiles
):
user = users.get(username="test1")
assert user.profile.is_interested_in_mobility is False
url = reverse("account:profiles-detail", args=[user.id])
patch(api_client_authenticated, url, {"is_interested_in_mobility": True})
user.refresh_from_db()
assert user.profile.is_interested_in_mobility is True


@pytest.mark.django_db
def test_profile_patch_geneder(api_client_authenticated, users, profiles):
user = users.get(username="test1")
Expand Down
Loading