Skip to content

Commit

Permalink
Include description and joining date in mention model
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomilov committed Feb 13, 2025
1 parent 8002f93 commit d744146
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions h/presenters/mention_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pyramid.request import Request

from h.models import Mention
from h.util.datetime import utc_iso8601
from h.util.user import format_userid, get_user_url


Expand All @@ -22,4 +23,6 @@ def asdict(self) -> dict[str, Any]:
"username": self._mention.user.username,
"display_name": self._mention.user.display_name,
"link": get_user_url(self._mention.user, self._request),
"description": self._mention.user.description,
"activation_date": utc_iso8601(self._mention.user.activation_date),
}
9 changes: 8 additions & 1 deletion tests/unit/h/presenters/mention_json_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import factory
import pytest

from h.models import Mention
from h.presenters.mention_json import MentionJSONPresenter
from h.util.datetime import utc_iso8601
from h.util.user import format_userid


Expand All @@ -17,6 +19,8 @@ def test_as_dict(self, user, annotation, pyramid_request):
"username": user.username,
"display_name": user.display_name,
"link": f"http://example.com/users/{user.username}",
"description": user.description,
"activation_date": utc_iso8601(user.activation_date),
}

def test_as_dict_with_different_username(self, user, annotation, pyramid_request):
Expand All @@ -29,7 +33,10 @@ def test_as_dict_with_different_username(self, user, annotation, pyramid_request

@pytest.fixture
def user(self, factories):
return factories.User.build()
return factories.User.build(
description="user description",
activation_date=factory.Faker("date_time_this_decade"),
)

@pytest.fixture
def annotation(self, factories):
Expand Down

0 comments on commit d744146

Please sign in to comment.