Skip to content

Commit

Permalink
Update tests, mock android sync endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Jul 9, 2024
1 parent 37cbf8a commit bcb0a2d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion temba/channels/types/android/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
from temba.contacts.models import URN
from temba.orgs.models import Org
from temba.tests import CRUDLTestMixin, TembaTest
from temba.tests.mailroom import mock_mailroom
from temba.utils import get_anonymous_user

from ...models import Channel


class AndroidTypeTest(TembaTest, CRUDLTestMixin):
def test_claim(self):

@mock_mailroom
def test_claim(self, mr_mocks):
# remove our explicit country so it needs to be derived from channels
self.org.country = None
self.org.timezone = "UTC"
Expand Down
4 changes: 3 additions & 1 deletion temba/mailroom/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import timedelta
from unittest.mock import patch

from django_redis import get_redis_connection

Expand Down Expand Up @@ -71,7 +72,8 @@ def test_queue_contact_import_batch(self):
},
)

def test_queue_interrupt_channel(self):
@patch("temba.channels.models.Channel.trigger_sync")
def test_queue_interrupt_channel(self, mock_trigger_sync):
self.channel.release(self.admin)

self.assert_org_queued(self.org, "batch")
Expand Down
6 changes: 4 additions & 2 deletions temba/orgs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ def test_ui_management(self):
self.editor.refresh_from_db()
self.assertFalse(self.editor.is_active)

def test_release(self):
@mock_mailroom
def test_release(self, mr_mocks):
# admin doesn't "own" any orgs
self.assertEqual(0, len(self.admin.get_owned_orgs()))

Expand Down Expand Up @@ -3381,7 +3382,8 @@ def test_update(self):
self.assertEqual("", self.editor.last_name)
self.assertEqual({alphas}, set(self.editor.groups.all()))

def test_delete(self):
@mock_mailroom
def test_delete(self, mr_mocks):
delete_url = reverse("orgs.user_delete", args=[self.editor.id])

# this is a customer support only view
Expand Down
3 changes: 3 additions & 0 deletions temba/tests/mailroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ def android_message(self, org, channel, phone: str, text: str, received_on):
)
return {"id": msg.id, "duplicate": False}

def android_sync(self, channel, registration_id=None):
return {"id": channel.id}

@_client_method
def contact_create(self, org, user, contact: mailroom.ContactSpec):
return create_contact_locally(
Expand Down
4 changes: 3 additions & 1 deletion temba/triggers/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from temba.flows.models import Flow
from temba.schedules.models import Schedule
from temba.tests import CRUDLTestMixin, TembaTest
from temba.tests.mailroom import mock_mailroom
from temba.utils.views import TEMBA_MENU_SELECTION

from .models import Trigger
Expand Down Expand Up @@ -567,7 +568,8 @@ def test_menu(self):
# the archived trigger not counted
self.assertPageMenu(menu_url, self.user, ["Active (1)", "Archived (1)", "Messages (1)"])

def test_create(self):
@mock_mailroom
def test_create(self, mr_mocks):
create_url = reverse("triggers.trigger_create")
create_new_convo_url = reverse("triggers.trigger_create_new_conversation")
create_inbound_call_url = reverse("triggers.trigger_create_inbound_call")
Expand Down

0 comments on commit bcb0a2d

Please sign in to comment.