-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render page notes differently than annotations
- Loading branch information
Showing
4 changed files
with
77 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,27 +41,57 @@ def test_format_empty_annotations(): | |
assert not format_annotations([]) | ||
|
||
|
||
def test_format_annotation_without_title(): | ||
annotation = { | ||
"user": "acct:[email protected]", | ||
"uri": "https://example.com/", | ||
"links": {"incontext": "https://hyp.is/test_annotation_id_1/example.com/"}, | ||
"user_info": {"display_name": "md............................"}, | ||
} | ||
|
||
assert _format_annotation(annotation) == { | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "`test_user_1` (md............................) annotated https://example.com/:", | ||
}, | ||
"fields": [ | ||
{"type": "mrkdwn", "text": "*Quote:*"}, | ||
{ | ||
class TestFormatAnnotation: | ||
def test_without_title(self): | ||
annotation = { | ||
"user": "acct:[email protected]", | ||
"uri": "https://example.com/", | ||
"links": {"incontext": "https://hyp.is/test_annotation_id_1/example.com/"}, | ||
"user_info": {"display_name": "md............................"}, | ||
"target": [ | ||
{ | ||
"source": "https://web.hypothes.is/blog/step-by-step-guide-to-using-hypothesis-for-collaborative-projects/", | ||
"selector": [{"exact": "Annotated text"}], | ||
} | ||
], | ||
} | ||
|
||
assert _format_annotation(annotation) == { | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Annotation* (<https://hyp.is/test_annotation_id_1/example.com/|in-context link>):", | ||
"text": "`test_user_1` (md............................) annotated https://example.com/:", | ||
}, | ||
{"type": "plain_text", "text": "(None)"}, | ||
{"type": "plain_text", "text": "(None)"}, | ||
], | ||
} | ||
"fields": [ | ||
{"type": "mrkdwn", "text": "*Quote:*"}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Annotation* (<https://hyp.is/test_annotation_id_1/example.com/|in-context link>):", | ||
}, | ||
{"type": "plain_text", "text": "Annotated text"}, | ||
{"type": "plain_text", "text": "(None)"}, | ||
], | ||
} | ||
|
||
def test_page_note(self): | ||
annotation = { | ||
"user": "acct:[email protected]", | ||
"uri": "https://example.com/", | ||
"links": {"incontext": "https://hyp.is/test_annotation_id_1/example.com/"}, | ||
"user_info": {"display_name": "md............................"}, | ||
} | ||
|
||
assert _format_annotation(annotation) == { | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "`test_user_1` (md............................) annotated https://example.com/:", | ||
}, | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Page Note* (<https://hyp.is/test_annotation_id_1/example.com/|in-context link>):", | ||
}, | ||
{"type": "plain_text", "text": "(None)"}, | ||
], | ||
} |