Skip to content

Commit

Permalink
Use the badge description is the message string representation
Browse files Browse the repository at this point in the history
Fixes: fedora-infra#8
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed May 31, 2024
1 parent 41a15a8 commit 1a5ecb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tahrir_messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def agent_name(self):
def summary(self):
return f"{self.agent_name} was awarded the badge `{self.body['badge']['name']}`"

def __str__(self):
return self.body["badge"]["description"]

badge_schema: typing.ClassVar = {
"type": "object",
"required": ["badge_id", "description", "image_url", "name"],
Expand All @@ -91,7 +94,7 @@ def summary(self):
body_schema: typing.ClassVar = {
"id": "http://fedoraproject.org/message-schema/tahrir",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "The message sent when a user logs into tahrir for the first time",
"description": "The message sent when a badge is awarded",
"type": "object",
"required": ["user", "badge"],
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_badge_award():
expected_summary = "dudemcpants was awarded the badge `White Hat`"
assert message.topic == "badges.badge.award"
assert message.summary == expected_summary
assert str(message) == expected_summary
assert str(message) == DUMMY_BADGE["description"]
assert message.agent_name == "dudemcpants"
assert message.usernames == ["dudemcpants"]
assert message.app_name == "tahrir"
Expand Down

0 comments on commit 1a5ecb9

Please sign in to comment.