Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak5598 committed Jul 2, 2024
1 parent d1aec75 commit 8b94d14
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 178 deletions.
23 changes: 0 additions & 23 deletions tests/plugins/test_handle_messages.py

This file was deleted.

52 changes: 0 additions & 52 deletions tests/plugins/test_project.py

This file was deleted.

68 changes: 0 additions & 68 deletions tests/plugins/test_repo.py

This file was deleted.

75 changes: 40 additions & 35 deletions tests/test_welcome_plugin.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
# from unittest.mock import AsyncMock, patch

# import pytest

# from lettuce.plugins.welcome.welcome import WelcomePlugin


# @pytest.mark.asyncio
# async def test_welcome_plugin(mocker):
# mock_client = mocker.Mock()
# mock_settings = mocker.Mock()
# mock_storage = mocker.Mock()

# welcome_message_content = "Hello, <@{user_id}>! Welcome!"

# plugin = WelcomePlugin(client=mock_client, settings=mock_settings, storage=mock_storage)
# with patch.object(plugin, "welcome_message_template", welcome_message_content):
# plugin.say = AsyncMock()

# event = {"user": {"id": "U1234567890"}}

# # Mock the conversations_open API response using patch
# with patch.object(
# plugin.web_client,
# "conversations_open",
# AsyncMock(return_value={"channel": {"id": "D1234567890"}}),
# ):
# await plugin.welcome(event)

# expected_message = welcome_message_content.strip().format(user_id="U1234567890")
# plugin.say.assert_called_once_with(
# channel="D1234567890",
# text="Welcome to the OWASP Slack Community!",
# blocks=[{"type": "section", "text": {"type": "mrkdwn", "text": expected_message}}],
# )
def test_handle_team_join():
user_id = "D0730R9KFC2"
with open("welcome_message.txt", "r", encoding="utf-8") as file:
welcome_message_template = file.read()

welcome_message = welcome_message_template.format(user_id=user_id)

expected_message = (
":tada: *Welcome to the OWASP Slack Community, <@D0730R9KFC2>!* :tada:\n\n"
"We're thrilled to have you here! Whether you're new to OWASP or a long-time contributor, "
"this Slack workspace is the perfect place to connect, collaborate, and stay informed "
"about all things OWASP.\n\n"
":small_blue_diamond: *Get Involved:*\n"
"• Check out the *#contribute* channel to find ways to get involved with OWASP"
" projects and initiatives.\n"
"• Explore individual project channels, which are named *#project-name*,"
" to dive into specific projects that interest you.\n"
"• Join our chapter channels, named *#chapter-name*, to connect with "
"local OWASP members in your area.\n\n"
":small_blue_diamond: *Stay Updated:*\n"
"• Visit *#newsroom* for the latest updates and announcements.\n"
"• Follow *#external-activities* for news about OWASP's engagement "
"with the wider security community.\n\n"
":small_blue_diamond: *Connect and Learn:*\n"
"• *#jobs*: Looking for new opportunities? Check out the latest job postings here.\n"
"• *#leaders*: Connect with OWASP leaders and stay informed about leadership activities.\n"
"• *#project-committee*: Engage with the committee overseeing OWASP projects.\n"
"• *#gsoc*: Stay updated on Google Summer of Code initiatives.\n"
"• *#github-admins*: Get support and discuss issues "
"related to OWASP's GitHub repositories.\n"
"• *#learning*: Share and find resources to expand your knowledge "
"in the field of application security.\n\n"
"We're excited to see the amazing contributions you'll make. "
"If you have any questions or need assistance, don't hesitate to ask. "
"Let's work together to make software security visible and improve the"
" security of the software we all rely on.\n\n"
"Welcome aboard! :rocket:"
)

assert welcome_message.strip() == expected_message.strip()

0 comments on commit 8b94d14

Please sign in to comment.