2020-05-26 07:16:25 +02:00
|
|
|
from unittest.mock import MagicMock, patch
|
2019-03-28 21:32:28 +01:00
|
|
|
|
2018-01-06 12:11:44 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2018-01-06 12:11:44 +01:00
|
|
|
class IntercomWebHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'test'
|
|
|
|
URL_TEMPLATE = "/api/v1/external/intercom?&api_key={api_key}&stream={stream}"
|
|
|
|
FIXTURE_DIR_NAME = 'intercom'
|
|
|
|
|
2019-03-28 21:32:28 +01:00
|
|
|
@patch('zerver.webhooks.intercom.view.check_send_webhook_message')
|
|
|
|
def test_ping_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:
|
|
|
|
self.url = self.build_webhook_url()
|
|
|
|
payload = self.get_body('ping')
|
|
|
|
result = self.client_post(self.url, payload, content_type="application/json")
|
|
|
|
self.assertFalse(check_send_webhook_message_mock.called)
|
|
|
|
self.assert_json_success(result)
|
|
|
|
|
|
|
|
def test_company_created(self) -> None:
|
|
|
|
expected_topic = "Companies"
|
|
|
|
expected_message = """
|
|
|
|
New company **Kandra Labs** created:
|
|
|
|
* **User count**: 1
|
|
|
|
* **Monthly spending**: 0
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'company_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_contact_added_email(self) -> None:
|
|
|
|
expected_topic = "Contact: Azure Bus from St. John's"
|
|
|
|
expected_message = "New email jerryguitarist@gmail.com added to contact."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'contact_added_email',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_contact_created(self) -> None:
|
|
|
|
expected_topic = "Contact: Azure Bus from St. John's"
|
|
|
|
expected_message = """
|
|
|
|
New contact created:
|
|
|
|
* **Name (or pseudonym)**: Azure Bus from St. John's
|
|
|
|
* **Email**: aaron@zulip.com
|
|
|
|
* **Location**: St. John's, Newfoundland and Labrador, Canada
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'contact_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_contact_signed_up(self) -> None:
|
|
|
|
expected_topic = "User: Lilac Raindrop from St. John's"
|
|
|
|
expected_message = """
|
|
|
|
Contact signed up:
|
|
|
|
* **Email**: iago@zulip.com
|
|
|
|
* **Location**: St. John's, Newfoundland and Labrador, Canada
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'contact_signed_up',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_contact_tag_created(self) -> None:
|
|
|
|
expected_topic = "Contact: Eeshan Garg"
|
|
|
|
expected_message = "Contact tagged with the `developer` tag."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'contact_tag_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_contact_tag_deleted(self) -> None:
|
|
|
|
expected_topic = "Contact: Eeshan Garg"
|
|
|
|
expected_message = "The tag `developer` was removed from the contact."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'contact_tag_deleted',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_assigned(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = "Tim Abbott assigned to conversation."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_assigned',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_opened(self) -> None:
|
|
|
|
expected_topic = "Lead: Cordelia Lear"
|
|
|
|
expected_message = "Eeshan Garg opened the conversation."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_opened',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_closed(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = "Cordelia Lear closed the conversation."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_closed',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_snoozed(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = "Cordelia Lear snoozed the conversation."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_snoozed',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_unsnoozed(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = "Cordelia Lear unsnoozed the conversation."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_unsnoozed',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_replied(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = """
|
|
|
|
Cordelia Lear replied to the conversation:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Hey Eeshan! How can I help?
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_replied',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_noted(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = """
|
|
|
|
Cordelia Lear added a note to the conversation:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Talk to Tim about this user's query.
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_noted',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_admin_single_created(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = """
|
|
|
|
Cordelia Lear initiated a conversation:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Hi Eeshan, What's up
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_admin_single_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_user_created(self) -> None:
|
|
|
|
expected_topic = "Lead: Rose Poodle from St. John's"
|
|
|
|
expected_message = """
|
|
|
|
Rose Poodle from St. John's initiated a conversation:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Hello everyone!
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_user_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_conversation_user_replied(self) -> None:
|
|
|
|
expected_topic = "Lead: Eeshan Garg"
|
|
|
|
expected_message = """
|
|
|
|
Eeshan Garg replied to the conversation:
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
Well, I need some help getting access to a developer account.
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'conversation_user_replied',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_event_created(self) -> None:
|
|
|
|
expected_topic = "Events"
|
|
|
|
expected_message = "New event **invited-friend** created."
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'event_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_user_created(self) -> None:
|
|
|
|
expected_topic = "User: Aaron Smith"
|
|
|
|
expected_message = """
|
|
|
|
New user created:
|
|
|
|
* **Name**: Aaron Smith
|
|
|
|
* **Email**: aaron@zulip.com
|
|
|
|
""".strip()
|
|
|
|
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_created',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_user_deleted(self) -> None:
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_deleted',
|
|
|
|
'User: jerryguitarist@gmail.com',
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
'User deleted.',
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_user_email_updated(self) -> None:
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_email_updated',
|
|
|
|
'Contact: Azure Bus from St. John\'s',
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
'User\'s email was updated to aaron@zulip.com.',
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_user_tag_created(self) -> None:
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_tag_created',
|
|
|
|
'User: eeshangarg',
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
'The tag `developer` was added to the user.',
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_user_tag_deleted(self) -> None:
|
|
|
|
expected_topic = 'User: eeshangarg'
|
|
|
|
expected_message = 'The tag `CSV Import - 2019-03-26 22:46:04 UTC` was removed from the user.'
|
|
|
|
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_tag_deleted',
|
|
|
|
expected_topic,
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
expected_message,
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
2018-01-06 12:11:44 +01:00
|
|
|
|
2019-03-28 21:32:28 +01:00
|
|
|
def test_user_unsubscribed(self) -> None:
|
|
|
|
self.send_and_test_stream_message(
|
|
|
|
'user_unsubscribed',
|
|
|
|
'Contact: Eeshan Garg',
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
'User unsubscribed from emails.',
|
2019-03-28 21:32:28 +01:00
|
|
|
)
|
2018-01-06 12:11:44 +01:00
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> str:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data('intercom', fixture_name, file_type="json")
|