Refactor codebase to by DRY
This commit is contained in:
parent
c925079e8b
commit
83a526c533
13 changed files with 320 additions and 131 deletions
|
|
@ -157,7 +157,7 @@ def test_templates():
|
|||
|
||||
|
||||
async def test_hook():
|
||||
r = await hook.parse_event("Issue Hook", issue_open_payload)
|
||||
r = await hook.handle_event("Issue Hook", issue_open_payload)
|
||||
assert r[0]
|
||||
assert r[0][0] == "[gitlabhq/gitlab-test] root opened [issue #23](http://example.com/diaspora/issues/23): New API: create/update/delete file\n \n> Create new API for manipulations with repository\nAPI"
|
||||
assert r[0][1] == "<strong data-mautrix-exclude-plaintext>[<a data-mautrix-exclude-plaintext href=\"http://example.com/gitlabhq/gitlab-test\">gitlabhq/gitlab-test</a>]</strong> <a data-mautrix-exclude-plaintext href=\"http://example.com/root\">root</a>\n opened <a href=\"http://example.com/diaspora/issues/23\" >issue #23</a>: New API: create/update/delete file<br/>\n <blockquote><p>Create new API for manipulations with repository</p>\n</blockquote>\n <span data-mx-color=\"#000000\"\n data-mx-bg-color=\"#ffffff\"\n title=\"API related issues\"\n > API </span>"
|
||||
|
|
@ -44,19 +44,19 @@ sns_notification = """{
|
|||
"UnsubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:c9135db0-26c4-47ec-8998-413945fb5a96"
|
||||
}"""
|
||||
|
||||
def test_aws_sns_notification() -> None:
|
||||
r = aws.parse_sns_event(json.loads(sns_notification))
|
||||
assert r[0] == "My First Message\nHello world!"
|
||||
assert r[1] == "<strong><font color=#dc3545>My First Message</font></strong>\n<p>Hello world!</p>"
|
||||
async def test_aws_sns_notification() -> None:
|
||||
r = await aws.parse_sns_event(None, json.loads(sns_notification), None)
|
||||
assert r[0][0] == "My First Message\nHello world!"
|
||||
assert r[0][1] == "<strong><font color=#dc3545>My First Message</font></strong>\n<p>Hello world!</p>"
|
||||
|
||||
def test_aws_sns_subscribe() -> None:
|
||||
r = aws.parse_sns_event(json.loads(sns_subscribtion_confirm))
|
||||
async def test_aws_sns_subscribe() -> None:
|
||||
r = await aws.parse_sns_event(None, json.loads(sns_subscribtion_confirm), None)
|
||||
print(r)
|
||||
expected = 'You have chosen to subscribe to the topic arn:aws:sns:us-west-2:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.\n\nhttps://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=2336412f37...'
|
||||
assert r == (expected, expected)
|
||||
assert r[0] == (expected, expected)
|
||||
|
||||
def test_aws_sns_unsubscribe() -> None:
|
||||
r = aws.parse_sns_event(json.loads(sns_subscribtion_unsubscribe))
|
||||
async def test_aws_sns_unsubscribe() -> None:
|
||||
r = await aws.parse_sns_event(None, json.loads(sns_subscribtion_unsubscribe), None)
|
||||
print(r)
|
||||
expected = 'You have chosen to deactivate subscription arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55.\nTo cancel this operation and restore the subscription, visit the SubscribeURL included in this message.\n\nhttps://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=2336412f37fb6...'
|
||||
assert r == (expected, expected)
|
||||
assert r[0] == (expected, expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue