Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviamclaughlin authored Mar 8, 2024
1 parent d94ce21 commit daf189d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 45 deletions.
1 change: 0 additions & 1 deletion app/integrations/google_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ def find_heading_indices(content, start_heading, end_heading):
return start_index, end_index



# Replace the text between the headings
def replace_text_between_headings(doc_id, new_content, start_heading, end_heading):
# Setup the service
Expand Down
79 changes: 69 additions & 10 deletions app/tests/intergrations/test_google_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,27 +573,86 @@ def test_no_headings_present_find_heading_indices():
content = [
{
"paragraph": {
"elements": [{"startIndex": 1, "endIndex": 10, "textRun": {"content": "Some text"}}]
"elements": [
{
"startIndex": 1,
"endIndex": 10,
"textRun": {"content": "Some text"},
}
]
}
}
]
assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (None, None)
assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (
None,
None,
)


def test_only_start_heading_present_find_heading_indices():
content = [{"paragraph": {"elements": [{"startIndex": 1, "endIndex": 13, "textRun": {"content": START_HEADING}}]}}]
assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (13, None)

content = [
{
"paragraph": {
"elements": [
{
"startIndex": 1,
"endIndex": 13,
"textRun": {"content": START_HEADING},
}
]
}
}
]
assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (
13,
None,
)


def test_both_headings_present_find_heading_indices():
content = [
{"paragraph": {"elements": [{"startIndex": 1, "endIndex": 14, "textRun": {"content": START_HEADING, "endIndex": 13}}]}},
{"paragraph": {"elements": [{"startIndex": 17, "endIndex": 24, "textRun": {"content": "Some text", "endIndex": 22}}]}},
{"paragraph": {"elements": [{"startIndex": 25, "endIndex": 34, "textRun": {"content": END_HEADING, "startIndex": 23, "endIndex": 33}}]}}
{
"paragraph": {
"elements": [
{
"startIndex": 1,
"endIndex": 14,
"textRun": {"content": START_HEADING, "endIndex": 13},
}
]
}
},
{
"paragraph": {
"elements": [
{
"startIndex": 17,
"endIndex": 24,
"textRun": {"content": "Some text", "endIndex": 22},
}
]
}
},
{
"paragraph": {
"elements": [
{
"startIndex": 25,
"endIndex": 34,
"textRun": {
"content": END_HEADING,
"startIndex": 23,
"endIndex": 33,
},
}
]
}
},
]
assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (14, 25)

assert google_drive.find_heading_indices(content, START_HEADING, END_HEADING) == (
14,
25,
)


@patch("integrations.google_drive.list_metadata")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_entries_out_of_order_rearrange_by_datetime_ascending():

def test_invalid_entries_rearrange_by_datetime_ascending():
input_text = """
➡️ Invalid Entry
➡️ Invalid Entry
➡️ [2024-03-07 10:00:00 ET](https://example.com/link2) Jane Smith: Message two
"""
expected_output = "➡️ [2024-03-07 10:00:00 ET](https://example.com/link2) Jane Smith: Message two\n"
Expand Down
38 changes: 5 additions & 33 deletions app/tests/modules/incident/test_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,35 +1046,6 @@ def test_handle_reaction_added_adding_new_message_to_timeline_user_handle():
mock_client.users_profile_get.assert_called_once()


def test_handle_reaction_added_adding_new_message_to_timeline_user_handle():
logger = MagicMock()
mock_client = MagicMock()
mock_client.conversations_info.return_value = {"channel": {"name": "incident-123"}}
mock_client.conversations_history.return_value = {
"ok": True,
"messages": [
{
"type": "message",
"user": "U123ABC456",
"text": "<U123ABC456> says Sample test message",
"ts": "1512085950.000216",
}
],
}
body = {
"event": {
"reaction": "floppy_disk",
"item": {"channel": "C123456", "ts": "123456"},
}
}

incident.handle_reaction_added(mock_client, lambda: None, body, logger)

# Make assertion that the function calls the correct functions
mock_client.conversations_history.assert_called_once()
mock_client.bookmarks_list.assert_called_once()
mock_client.users_profile_get.assert_called_once()

def test_handle_reaction_added_returns_link():
logger = MagicMock()
mock_client = MagicMock()
Expand All @@ -1091,10 +1062,10 @@ def test_handle_reaction_added_returns_link():
],
}
mock_client.chat_getPermalink.return_value = {
"ok": "true",
"channel": "C123456",
"permalink": "https://example.com",
}
"ok": "true",
"channel": "C123456",
"permalink": "https://example.com",
}
body = {
"event": {
"reaction": "floppy_disk",
Expand All @@ -1110,6 +1081,7 @@ def test_handle_reaction_added_returns_link():
mock_client.users_profile_get.assert_called_once()
mock_client.chat_getPermalink.assert_called_once()


def test_handle_reaction_removed_successful_message_removal():
# Mock the client and logger
logger = MagicMock()
Expand Down

0 comments on commit daf189d

Please sign in to comment.