Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
7e14b0db
Commit
7e14b0db
authored
2 years ago
by
sandeepsajan0
Committed by
Fredrik Jonsson
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add slack token settings to test
parent
aed8cba5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hypha/apply/activity/tests/test_messaging.py
+40
-10
40 additions, 10 deletions
hypha/apply/activity/tests/test_messaging.py
with
40 additions
and
10 deletions
hypha/apply/activity/tests/test_messaging.py
+
40
−
10
View file @
7e14b0db
...
@@ -6,6 +6,7 @@ from unittest.mock import Mock, patch
...
@@ -6,6 +6,7 @@ from unittest.mock import Mock, patch
import
responses
import
responses
from
django.contrib.messages
import
get_messages
from
django.contrib.messages
import
get_messages
from
django.core
import
mail
from
django.core
import
mail
from
django.conf
import
settings
from
django.test
import
TestCase
,
override_settings
from
django.test
import
TestCase
,
override_settings
from
django_slack.utils
import
get_backend
from
django_slack.utils
import
get_backend
...
@@ -331,14 +332,17 @@ class TestActivityAdapter(TestCase):
...
@@ -331,14 +332,17 @@ class TestActivityAdapter(TestCase):
class
TestSlackAdapter
(
AdapterMixin
,
TestCase
):
class
TestSlackAdapter
(
AdapterMixin
,
TestCase
):
source_factory
=
ApplicationSubmissionFactory
source_factory
=
ApplicationSubmissionFactory
backend
=
'
django_slack.backends.TestBackend
'
target_url
=
'
https://my-slack-backend.com/incoming/my-very-secret-key
'
target_url
=
'
https://my-slack-backend.com/incoming/my-very-secret-key
'
target_room
=
'
#<ROOM ID>
'
target_room
=
'
#<ROOM ID>
'
token
=
'
fake-token
'
@override_settings
(
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
None
,
SLACK_DESTINATION_ROOM
=
None
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_cant_send_with_no_room
(
self
):
def
test_cant_send_with_no_room
(
self
):
error_message
=
"
Missing configuration: Room ID
"
error_message
=
"
Missing configuration: Room ID
"
...
@@ -351,7 +355,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
...
@@ -351,7 +355,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
SLACK_DESTINATION_URL
=
None
,
SLACK_DESTINATION_URL
=
None
,
SLACK_ENDPOINT_URL
=
None
,
SLACK_ENDPOINT_URL
=
None
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_cant_send_with_no_url
(
self
):
def
test_cant_send_with_no_url
(
self
):
error_message
=
"
Missing configuration: Destination URL
"
error_message
=
"
Missing configuration: Destination URL
"
...
@@ -364,7 +369,23 @@ class TestSlackAdapter(AdapterMixin, TestCase):
...
@@ -364,7 +369,23 @@ class TestSlackAdapter(AdapterMixin, TestCase):
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
None
,
)
def
test_cant_send_with_no_token
(
self
):
error_message
=
"
Missing configuration: Slack Token
"
adapter
=
SlackAdapter
()
submission
=
ApplicationSubmissionFactory
()
messages
=
adapter
.
send_message
(
'
my message
'
,
''
,
source
=
submission
)
self
.
assertEqual
(
messages
,
error_message
)
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_correct_payload
(
self
):
def
test_correct_payload
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -382,7 +403,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
...
@@ -382,7 +403,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_fund_custom_slack_channel
(
self
):
def
test_fund_custom_slack_channel
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -402,7 +424,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
...
@@ -402,7 +424,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_fund_multiple_custom_slack_channel
(
self
):
def
test_fund_multiple_custom_slack_channel
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -434,7 +457,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
...
@@ -434,7 +457,8 @@ class TestSlackAdapter(AdapterMixin, TestCase):
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_ENDPOINT_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_message_with_good_response
(
self
):
def
test_message_with_good_response
(
self
):
self
.
adapter
=
SlackAdapter
()
self
.
adapter
=
SlackAdapter
()
...
@@ -577,8 +601,10 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
...
@@ -577,8 +601,10 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
activity
=
ActivityAdapter
activity
=
ActivityAdapter
source_factory
=
ProjectFactory
source_factory
=
ProjectFactory
# Slack
# Slack
backend
=
'
django_slack.backends.TestBackend
'
target_url
=
'
https://my-slack-backend.com/incoming/my-very-secret-key
'
target_url
=
'
https://my-slack-backend.com/incoming/my-very-secret-key
'
target_room
=
'
#<ROOM ID>
'
target_room
=
'
#<ROOM ID>
'
token
=
'
fake-token
'
def
test_activity_lead_change
(
self
):
def
test_activity_lead_change
(
self
):
old_lead
=
UserFactory
()
old_lead
=
UserFactory
()
...
@@ -622,7 +648,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
...
@@ -622,7 +648,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
@override_settings
(
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_slack_created
(
self
):
def
test_slack_created
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -644,7 +671,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
...
@@ -644,7 +671,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
@override_settings
(
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_slack_lead_change
(
self
):
def
test_slack_lead_change
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -666,7 +694,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
...
@@ -666,7 +694,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
@override_settings
(
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_slack_applicant_update_invoice
(
self
):
def
test_slack_applicant_update_invoice
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
@@ -691,7 +720,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
...
@@ -691,7 +720,8 @@ class TestAdaptersForProject(AdapterMixin, TestCase):
@override_settings
(
@override_settings
(
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_URL
=
target_url
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_DESTINATION_ROOM
=
target_room
,
SLACK_BACKEND
=
"
django_slack.backends.TestBackend
"
,
SLACK_BACKEND
=
backend
,
SLACK_TOKEN
=
token
,
)
)
def
test_slack_staff_update_invoice
(
self
):
def
test_slack_staff_update_invoice
(
self
):
backend
=
get_backend
()
backend
=
get_backend
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment