-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Update feature flag keys #1192
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
962eec4
refactor: Update feature flag keys and improve error logging in AuthS…
abdullai-t 922eee7
test: Add unit tests for community admin testimonial nudge functionality
abdullai-t 69b20c0
test: Remove debug print statement from CadminTestimonialNudge test
abdullai-t a807c71
refactor: Improve community admin authorization check in EventStore
abdullai-t 14a47f6
refactor: Remove unnecessary user_info parameter from send_events_rep…
abdullai-t e25bd49
fix: Handle case where community may be None in Action model serializ…
abdullai-t 8b3cd89
refactor: Simplify admin authorization check in EventStore and enhanc…
abdullai-t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from django.test.testcases import TestCase | ||
from _main_.utils.feature_flag_keys import TESTIMONIAL_AUTO_SHARE_SETTINGS_NUDGE_FEATURE_FLAG_KEY | ||
from _main_.utils.utils import Console | ||
from api.tests.common import make_feature_flag, make_testimonial_auto_share_settings, makeAdmin, makeCommunity, makeTestimonial, makeUser | ||
from database.models import TestimonialSharedCommunity | ||
from database.utils.settings.model_constants.enums import SharingType | ||
from task_queue.nudges.cadmin_testimonial_nudge import get_cadmin_names_and_emails, prepare_testimonials_for_community_admins | ||
from django.utils import timezone | ||
|
||
class CadminTestimonialNudgeTestCases(TestCase): | ||
|
||
def setUp(self): | ||
self.c1 = makeCommunity(name="Test Community 1") | ||
self.c2 = makeCommunity(name="Test Community 2") | ||
self.c3 = makeCommunity(name="Test Community 3") | ||
self.c4 = makeCommunity(name="Test Community 4") | ||
self.c5 = makeCommunity(name="Test Community 5") | ||
|
||
user = makeUser(email="[email protected]", full_name="Test Admin") | ||
user1 = makeUser(email="[email protected]", full_name="Test Admin 1") | ||
user2 = makeUser(email="[email protected]", full_name="Test Admin 2") | ||
user3 = makeUser(email="[email protected]", full_name="Test Admin 3") | ||
user4 = makeUser(email="[email protected]", full_name="Test Admin 4") | ||
makeAdmin(communities=[self.c1],admin=user) | ||
makeAdmin(communities=[self.c2],admin=user1) | ||
makeAdmin(communities=[self.c3],admin=user2) | ||
makeAdmin(communities=[self.c4],admin=user3) | ||
makeAdmin(communities=[self.c1],admin=user4) | ||
|
||
|
||
make_feature_flag( | ||
key=TESTIMONIAL_AUTO_SHARE_SETTINGS_NUDGE_FEATURE_FLAG_KEY, | ||
communities=[self.c1, self.c2, self.c3, self.c4, self.c5], | ||
audience="EVERYONE", | ||
name="Testimonial Auto Share Settings Nudge" | ||
) | ||
|
||
t1 =makeTestimonial( | ||
community=self.c2, user=user, title="Testimonial shared to c2 c3, c5", | ||
sharing_type=SharingType.OPEN_TO.value[0], audience=[self.c2, self.c3, self.c5], | ||
is_published=True, | ||
published_at=timezone.now() | ||
) | ||
t2 = makeTestimonial( | ||
community=self.c3, user=user, title="Testimonial shared to none", | ||
sharing_type=SharingType.OPEN.value[0], | ||
is_published=True, | ||
published_at=timezone.now() | ||
) | ||
t3 = makeTestimonial( | ||
community=self.c1, user=user, title="Testimonial shared to none for c1", | ||
sharing_type=SharingType.OPEN.value[0], | ||
is_published=True, | ||
published_at=timezone.now() | ||
) | ||
t4 = makeTestimonial( | ||
community=self.c3, user=user, title="Testimonial shared to none for c3", | ||
sharing_type=SharingType.OPEN.value[0], | ||
is_published=True, | ||
published_at=timezone.now() | ||
) | ||
TestimonialSharedCommunity.objects.create(community=self.c2, testimonial=t1) | ||
TestimonialSharedCommunity.objects.create(community=self.c3, testimonial=t1) | ||
TestimonialSharedCommunity.objects.create(community=self.c5, testimonial=t1) | ||
TestimonialSharedCommunity.objects.create(community=self.c1, testimonial=t3) | ||
TestimonialSharedCommunity.objects.create(community=self.c3, testimonial=t4) | ||
|
||
|
||
def tearDown(self): | ||
return super().tearDown() | ||
|
||
|
||
def test_get_cadmin_names_and_emails_success(self): | ||
|
||
Console.header("Test get_cadmin_names_and_emails_success for c1") | ||
|
||
data = get_cadmin_names_and_emails(self.c1) | ||
keys = data.keys() | ||
self.assertIn('[email protected]', keys) | ||
self.assertIn('[email protected]', keys) | ||
self.assertIsNotNone(data) | ||
|
||
|
||
|
||
def test_prepare_testimonials_for_community_admins_success(self): | ||
Console.header("Test prepare_testimonials_for_community_admins_success") | ||
task = None | ||
result = prepare_testimonials_for_community_admins(task) | ||
self.assertTrue(result) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# from django.test import TestCase | ||
from django.test import TestCase | ||
from unittest.mock import Mock | ||
from api.tests.common import makeMedia | ||
from website.views import _get_file_url | ||
|
||
# # Create your tests here. | ||
class GetFileUrlTests(TestCase): | ||
|
||
def setUp(self): | ||
self.m1 = makeMedia(name="m1") | ||
self.m2 = makeMedia(name="m2", file=None) | ||
|
||
def test_get_file_url_with_no_image(self): | ||
result = _get_file_url(None) | ||
self.assertEqual(result, "") | ||
|
||
def test_get_file_url_with_file(self): | ||
result = _get_file_url(self.m1) | ||
self.assertRegex(result, r'^/media/media/.*$') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add test coverage for this. @abdullai-t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.