Skip to content
Snippets Groups Projects
Commit 9127ae63 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-205: Adding work e-mail in sponsor API

parent 9b1c7689
No related branches found
No related tags found
1 merge request!276GREG-205: Adding work e-mail in sponsor API
......@@ -9,4 +9,4 @@ class SponsorSerializer(serializers.ModelSerializer):
class Meta:
model = Sponsor
fields = ["id", "feide_id", "first_name", "last_name", "orgunits"]
fields = ["id", "feide_id", "first_name", "last_name", "work_email", "orgunits"]
......@@ -524,12 +524,13 @@ class Sponsor(BaseModel):
return f"{self.feide_id} ({self.first_name} {self.last_name})"
def __repr__(self) -> str:
return "{}(id={!r}, feide_id={!r}, first_name={!r}, last_name={!r})".format(
return "{}(id={!r}, feide_id={!r}, first_name={!r}, last_name={!r}, work_email={!r})".format(
self.__class__.__name__,
self.pk,
self.feide_id,
self.first_name,
self.last_name,
self.work_email,
)
class Meta:
......
......@@ -18,6 +18,7 @@ def test_add_sponsor(client):
"feide_id": "sponsor@example.org",
"first_name": "Test",
"last_name": "Sponsor",
"work_email": "sponsor123@example.org",
}
post_response = client.post(reverse("v1:sponsor-list"), data=data)
......@@ -33,6 +34,7 @@ def test_add_sponsor(client):
assert list_response_data["feide_id"] == data["feide_id"]
assert list_response_data["first_name"] == data["first_name"]
assert list_response_data["last_name"] == data["last_name"]
assert list_response_data["work_email"] == data["work_email"]
@pytest.mark.django_db
......
......@@ -5,5 +5,6 @@ import pytest
def test_identity_repr(person_foo_verified):
assert (
repr(person_foo_verified)
== "Identity(id=3, person_id=1, type='passport_number', source='Test', value='12345', verified_by=Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy'), verified_at=datetime.datetime(2021, 6, 15, 12, 34, 56, tzinfo=datetime.timezone.utc))"
== "Identity(id=3, person_id=1, type='passport_number', source='Test', value='12345', verified_by=Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy', work_email='sponsor_guy@example.com'), "
"verified_at=datetime.datetime(2021, 6, 15, 12, 34, 56, tzinfo=datetime.timezone.utc))"
)
......@@ -56,7 +56,8 @@ def test_add_muliple_sponsors_to_unit(sponsor_foo, sponsor_bar, unit1, unit2):
def test_sponsor_repr(sponsor_guy):
assert (
repr(sponsor_guy)
== "Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy')"
== "Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy', "
"work_email='sponsor_guy@example.com')"
)
......
......@@ -5,5 +5,5 @@ import pytest
def test_sponsor_org_repr(sponsor_org_unit):
assert (
repr(sponsor_org_unit)
== "SponsorOrganizationalUnit(id=1, sponsor=Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy'), organizational_unit=OrganizationalUnit(id=1, name_en='foo_unit', parent=None), hierarchical_access=False)"
== "SponsorOrganizationalUnit(id=1, sponsor=Sponsor(id=1, feide_id='guy@example.org', first_name='Sponsor', last_name='Guy', work_email='sponsor_guy@example.com'), organizational_unit=OrganizationalUnit(id=1, name_en='foo_unit', parent=None), hierarchical_access=False)"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment