Skip to content
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
8 changes: 4 additions & 4 deletions app/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from arxiv.taxonomy.category import Category

class NotificationType(str, Enum):
COMMENT = 'Comment Added'
PROP_RESP = 'Category Proposal Responses'
NEW_PROP = 'New Category Proposal'
PROMOTE = 'Category Promotion'
COMMENT = 'comment-added'
PROP_RESP = 'proposal-response'
NEW_PROP = 'new-proposal'
PROMOTE = 'category-promotion'
#TODO should rejections eventually send emails?

#the shape the data comes in the pubsub message
Expand Down
32 changes: 16 additions & 16 deletions tests/test_process_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Comment Added",
"action": "comment-added",
"data": {"comment": "hello"}
}

Expand All @@ -23,7 +23,7 @@
"submission_id": 124,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Category Promotion",
"action": "category-promotion",
"data": {
"category": "cs.LG",
"promotion_type": "primary",
Expand All @@ -36,7 +36,7 @@
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Category Promotion",
"action": "category-promotion",
"data": {
"category": "cs.LG",
"promotion_type": "invalid", # bad enum
Expand All @@ -49,7 +49,7 @@
"submission_id": 123,
"user_id": 2,
"categories": ["hep-lat"],
"action": "Category Proposal Responses",
"action": "proposal-response",
"data": {
"responses": "Primary accepted: hep-lat",
"category_change": "no primary -> hep-lat"
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_general_parse():
"submission_id": 123,
"user_id": 1,
"categories": "cs.LG",
"action": "Comment Added",
"action": "comment-added",
"data": {"comment": "goodbye"}
}

Expand All @@ -109,7 +109,7 @@ def test_general_parse():
full_note, simple_note = _parse_message(bad2)

full_note, simple_note=_parse_message(GOOD_COMMENT)
assert full_note.action== "Comment Added"
assert full_note.action== "comment-added"
assert full_note.categories== ["cs.LG", "cs.AI"]
assert full_note.submission_id== 123
assert full_note.time == datetime(2024, 1, 1, 10, 0, tzinfo=timezone.utc)
Expand All @@ -120,15 +120,15 @@ def test_parse_comment():
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Comment Added",
"action": "comment-added",
"data": {"comment": 5}
}

with pytest.raises(Exception):
full_note, simple_note = _parse_message(bad_comment)

full_note, simple_note=_parse_message(GOOD_COMMENT)
assert full_note.action== "Comment Added"
assert full_note.action== "comment-added"
assert full_note.categories== ["cs.LG", "cs.AI"]
assert full_note.submission_id== 123
assert isinstance(simple_note.data, CommentData)
Expand All @@ -142,7 +142,7 @@ def test_parse_new_prop():
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "New Category Proposal",
"action": "new-proposal",
"data": {"msg": "new category request"}
}

Expand All @@ -151,7 +151,7 @@ def test_parse_new_prop():
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "New Category Proposal",
"action": "new-proposal",
"data": {"message": "new category request"}
}

Expand All @@ -160,7 +160,7 @@ def test_parse_new_prop():

full_note, simple_note = _parse_message(good_new_prop)

assert full_note.action == "New Category Proposal"
assert full_note.action == "new-proposal"
assert full_note.categories == ["cs.LG", "cs.AI"]
assert full_note.submission_id == 123

Expand All @@ -174,7 +174,7 @@ def test_parse_promote():

full_note, simple_note = _parse_message(GOOD_PROMOTE)

assert full_note.action == "Category Promotion"
assert full_note.action == "category-promotion"
assert full_note.categories == ["cs.LG", "cs.AI"]
assert full_note.submission_id == 124

Expand All @@ -191,7 +191,7 @@ def test_parse_prop_response():
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Category Proposal Responses",
"action": "proposal-response",
"data": {
"responses": 123, # invalid type
"category_change": "none"
Expand All @@ -203,7 +203,7 @@ def test_parse_prop_response():

full_note, simple_note = _parse_message(GOOD_PROP_RESP)

assert full_note.action == "Category Proposal Responses"
assert full_note.action == "proposal-response"
assert full_note.categories == ["hep-lat"]
assert full_note.submission_id == 123
assert full_note.time == datetime(2024, 1, 1, 10, 0, tzinfo=timezone.utc)
Expand Down Expand Up @@ -346,15 +346,15 @@ def test_changes_ordered_newest_first():
"submission_id": 123,
"user_id": 1,
"categories": ["cs.LG", "cs.AI"],
"action": "Comment Added",
"action": "comment-added",
"data": {"comment": "first comment"}
}
newer = {
"time": "2024-01-02T10:00:00Z",
"submission_id": 123,
"user_id": 2,
"categories": ["cs.LG", "cs.AI"],
"action": "Comment Added",
"action": "comment-added",
"data": {"comment": "second comment"}
}
# messages arrive in chronological order; rendered email should show newest first
Expand Down
Loading