Skip to content
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

feat(templates): Enhance I'm Now Following [#332] #530

Merged
merged 14 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bc/channel/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ class Meta:
group = SubFactory(GroupFactory)

class Params:
bluesky = factory.Trait(
service=Channel.BLUESKY,
account="BigCases2-faux.bsky.social",
account_id="Bigsky-big-cases-email-faux",
enabled=True,
)
mastodon = factory.Trait(
service=Channel.MASTODON,
account="BigCases2-faux",
account="@BigCases2-faux@mastodon.test",
account_id="Mastodon-big-cases-email-faux",
enabled=True,
)
Expand Down
20 changes: 13 additions & 7 deletions bc/core/management/commands/make_dev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,30 @@ def make_big_cases_group_and_channels(
self,
) -> tuple[Group | GroupFactory, str]:
"""
Make 1 big cases Group and 2 channels for it (Mastodon and Twitter)
Make 1 big cases Group and channels for it
(Bluesky, Mastodon, and Twitter)

:return: the big cases Group, a string saying that they were made
:rtype: tuple[Group | GroupFactory, str]
"""
info = "Big Cases Group and the Mastodon and Twitter Channels"
big_cases_group = self._make_group_and_2_channels(True, "Big cases")
info = (
"Big Cases Group and the Bluesky, Mastodon, and Twitter Channels"
)
big_cases_group = self._make_group_and_channels(True, "Big cases")
return big_cases_group, self._made_str(self.NUM_BIGCASES_GROUPS, info)

def make_little_cases_group_and_channels(
self,
) -> tuple[Group | GroupFactory, str]:
"""
Make 1 little cases Group and 2 channels for it (Mastodon and Twitter)
Make 1 little cases Group and channels for it
(Bluesky, Mastodon and Twitter)

:return: the little cases Group, a string saying that they were made
:rtype: tuple[Group | GroupFactory, str]
"""
info = "Little Cases Group and the Mastodon and Twitter Channels"
little_cases_group = self._make_group_and_2_channels(
info = "Little Cases Group and the Bluesky, Mastodon, and Twitter Channels"
little_cases_group = self._make_group_and_channels(
False, "Little cases"
)
return little_cases_group, self._made_str(
Expand Down Expand Up @@ -289,7 +293,7 @@ def subscribe_randoms_to_group(
)

@staticmethod
def _make_group_and_2_channels(
def _make_group_and_channels(
is_big_cases: bool = False, name: str | None = None
) -> Group | GroupFactory:
if name is None:
Expand All @@ -298,10 +302,12 @@ def _make_group_and_2_channels(
new_cases_group = GroupFactory.create(
name=name, is_big_cases=is_big_cases
)
bluesky_ch = ChannelFactory.create(bluesky=True, group=new_cases_group)
mastodon_ch = ChannelFactory.create(
mastodon=True, group=new_cases_group
)
twitter_ch = ChannelFactory.create(twitter=True, group=new_cases_group)
new_cases_group.channels.add(bluesky_ch)
new_cases_group.channels.add(mastodon_ch)
new_cases_group.channels.add(twitter_ch)
return new_cases_group
Expand Down
18 changes: 10 additions & 8 deletions bc/core/tests/test_make_dev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
# MagicMocks, so those lines are commented to ignore the [attr-defined]
# error.
import re
from typing import cast
from unittest.mock import ANY, MagicMock, call, patch

from django.test import SimpleTestCase

from bc.core.management.commands.make_dev_data import MakeDevData
from bc.subscription.tests.factories import SubscriptionFactory
from bc.subscription.utils.courtlistener import DocketDict

CL_DOCKET_RESULT = {
"docket_id": 42,
CL_DOCKET_RESULT: DocketDict = {
"id": 42,
"docket_number": "US 12345",
"case_name": "US v Bobolink",
"court_id": 5,
"pacer_case_id": 89,
"court_id": "5",
"pacer_case_id": "89",
"slug": "cl_slug_for_docket",
}

Expand All @@ -43,7 +45,7 @@ def test_default_values(self) -> None:
return_value=([], "subbed randoms"),
)
class TestCreate(SimpleTestCase):
cl_docket_result: dict[str, object] = {}
cl_docket_result = cast(DocketDict, {})
mock_big_cases_group: MagicMock = MagicMock()
mocked_make_big_cases_group_and_channels: MagicMock = MagicMock()
mocked_make_little_cases_group_and_channels: MagicMock = MagicMock()
Expand Down Expand Up @@ -404,7 +406,7 @@ def has_group_subscribed_str(
# @see https://docs.python.org/3/library/unittest.mock.html#where-to-patch
@patch("bc.core.management.commands.make_dev_data.lookup_docket_by_cl_id")
class TestMakeSubsFromClDocketId(NumSubdToGroupStrTest, SimpleTestCase):
cl_docket_result: dict[str, object] = {}
cl_docket_result: DocketDict = cast(DocketDict, {})
mocked_channels: MagicMock = MagicMock()
mock_big_cases_group: MagicMock = MagicMock()

Expand Down Expand Up @@ -447,8 +449,8 @@ def test_creates_subs_from_factory(
cl_docket_id=67890,
docket_number="US 12345",
docket_name="US v Bobolink",
cl_court_id=5,
pacer_case_id=89,
cl_court_id="5",
pacer_case_id="89",
cl_slug="cl_slug_for_docket",
channels=self.mock_big_cases_group.channels.all(),
)
Expand Down
Loading