Skip to content

Commit

Permalink
More cleanup of broadcast creation in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jun 19, 2024
1 parent a06de9c commit c9ec9fa
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 114 deletions.
4 changes: 3 additions & 1 deletion temba/api/v2/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4013,7 +4013,9 @@ def test_messages(self, mr_mocks):
)

# filter by broadcast
broadcast = self.create_broadcast(self.user, "A beautiful broadcast", contacts=[self.joe, self.frank])
broadcast = self.create_broadcast(
self.user, {"eng": {"text": "A beautiful broadcast"}}, contacts=[self.joe, self.frank]
)
self.assertGet(
endpoint_url + f"?broadcast={broadcast.id}",
[self.editor],
Expand Down
16 changes: 9 additions & 7 deletions temba/contacts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,11 @@ def test_scheduled(self):
# create scheduled and regular broadcasts which send to both groups
bcast1 = self.create_broadcast(
self.admin,
"Hi again",
{"eng": {"text": "Hi again"}},
contacts=[contact1, contact2],
schedule=Schedule.create(self.org, timezone.now() + timedelta(days=3), Schedule.REPEAT_DAILY),
)
self.create_broadcast(self.admin, "Bye", contacts=[contact1, contact2]) # not scheduled
self.create_broadcast(self.admin, {"eng": {"text": "Bye"}}, contacts=[contact1, contact2]) # not scheduled

# create scheduled trigger which this contact is explicitly added to
trigger1_flow = self.create_flow("Favorites 1")
Expand Down Expand Up @@ -1256,8 +1256,8 @@ def test_release(self, mr_mocks):

# create scheduled and regular broadcasts which send to both groups
schedule = Schedule.create(self.org, timezone.now(), Schedule.REPEAT_DAILY)
bcast1 = self.create_broadcast(self.admin, "Hi", groups=[group1, group2], schedule=schedule)
bcast2 = self.create_broadcast(self.admin, "Hi", groups=[group1, group2])
bcast1 = self.create_broadcast(self.admin, {"eng": {"text": "Hi"}}, groups=[group1, group2], schedule=schedule)
bcast2 = self.create_broadcast(self.admin, {"eng": {"text": "Hi"}}, groups=[group1, group2])
bcast2.send_async()

# group still has a hard dependency so can't be released
Expand Down Expand Up @@ -1763,8 +1763,10 @@ def test_release(self, mr_mocks):

# create scheduled and regular broadcasts which send to both contacts
schedule = Schedule.create(self.org, timezone.now(), Schedule.REPEAT_DAILY)
bcast1 = self.create_broadcast(self.admin, "Test", contacts=[contact, contact2], schedule=schedule)
bcast2 = self.create_broadcast(self.admin, "Test", contacts=[contact, contact2])
bcast1 = self.create_broadcast(
self.admin, {"eng": {"text": "Test"}}, contacts=[contact, contact2], schedule=schedule
)
bcast2 = self.create_broadcast(self.admin, {"eng": {"text": "Test"}}, contacts=[contact, contact2])

flow_nodes = msg_flow.get_definition()["nodes"]
color_prompt = flow_nodes[0]
Expand Down Expand Up @@ -2280,7 +2282,7 @@ def test_history(self):
self.joe.created_on = timezone.now() - timedelta(days=1000)
self.joe.save(update_fields=("created_on",))

self.create_broadcast(self.user, "A beautiful broadcast", contacts=[self.joe])
self.create_broadcast(self.user, {"eng": {"text": "A beautiful broadcast"}}, contacts=[self.joe])
self.create_campaign()

# add a message with some attachments
Expand Down
Loading

0 comments on commit c9ec9fa

Please sign in to comment.