def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts): mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key='contact-pull') self.assertEqual( task_state.get_last_results(), { 'fields': { 'created': 1, 'updated': 2, 'deleted': 3 }, 'boundaries': { 'created': 5, 'updated': 6, 'deleted': 7 }, 'contacts': { 'created': 9, 'updated': 10, 'deleted': 11 } }) mock_squash_counts.assert_called_once_with()
def test_pull_contacts( self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts, mock_get_backend ): mock_get_backend.return_value = TestBackend(self.rapidpro_backend) mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" # keep only on backend config self.nigeria.backends.exclude(slug="rapidpro").delete() pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key="contact-pull") self.assertEqual( task_state.get_last_results(), { "rapidpro": { "fields": {"created": 1, "updated": 2, "deleted": 3}, "boundaries": {"created": 5, "updated": 6, "deleted": 7}, "contacts": {"created": 9, "updated": 10, "deleted": 11}, } }, ) mock_squash_counts.assert_called_once_with()
def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts): mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key='contact-pull') self.assertEqual(task_state.get_last_results(), { 'fields': {'created': 1, 'updated': 2, 'deleted': 3}, 'boundaries': {'created': 5, 'updated': 6, 'deleted': 7}, 'contacts': {'created': 9, 'updated': 10, 'deleted': 11} }) mock_squash_counts.assert_called_once_with()
def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields): mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) with self.settings(CACHES={'default': {'BACKEND': 'redis_cache.cache.RedisCache', 'LOCATION': '127.0.0.1:6379:1', 'OPTIONS': {'CLIENT_CLASS': 'redis_cache.client.DefaultClient'} }}): pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key='contact-pull') self.assertEqual(task_state.get_last_results(), { 'fields': {'created': 1, 'updated': 2, 'deleted': 3}, 'boundaries': {'created': 5, 'updated': 6, 'deleted': 7}, 'contacts': {'created': 9, 'updated': 10, 'deleted': 11} })
def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts): mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" with self.settings( CACHES={ 'default': { 'BACKEND': 'redis_cache.cache.RedisCache', 'LOCATION': '127.0.0.1:6379:1', 'OPTIONS': { 'CLIENT_CLASS': 'redis_cache.client.DefaultClient' } } }): pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key='contact-pull') self.assertEqual( task_state.get_last_results(), { 'fields': { 'created': 1, 'updated': 2, 'deleted': 3 }, 'boundaries': { 'created': 5, 'updated': 6, 'deleted': 7 }, 'contacts': { 'created': 9, 'updated': 10, 'deleted': 11 } }) mock_squash_counts.assert_called_once_with()
def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts, mock_get_backend): mock_get_backend.return_value = TestBackend(self.rapidpro_backend) mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" # keep only on backend config self.nigeria.backends.exclude(slug="rapidpro").delete() pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key="contact-pull") self.assertEqual( task_state.get_last_results(), { "rapidpro": { "fields": { "created": 1, "updated": 2, "deleted": 3 }, "boundaries": { "created": 5, "updated": 6, "deleted": 7 }, "contacts": { "created": 9, "updated": 10, "deleted": 11 }, } }, ) mock_squash_counts.assert_called_once_with()
def test_pull_contacts(self, mock_pull_contacts, mock_pull_boundaries, mock_pull_fields, mock_squash_counts, mock_get_backend): mock_get_backend.return_value = TestBackend(self.rapidpro_backend) mock_pull_fields.return_value = (1, 2, 3, 4) mock_pull_boundaries.return_value = (5, 6, 7, 8) mock_pull_contacts.return_value = (9, 10, 11, 12) mock_squash_counts.return_value = "Called" # keep only on backend config self.nigeria.backends.exclude(slug='rapidpro').delete() pull_contacts(self.nigeria.pk) task_state = TaskState.objects.get(org=self.nigeria, task_key='contact-pull') self.assertEqual( task_state.get_last_results(), { 'rapidpro': { 'fields': { 'created': 1, 'updated': 2, 'deleted': 3 }, 'boundaries': { 'created': 5, 'updated': 6, 'deleted': 7 }, 'contacts': { 'created': 9, 'updated': 10, 'deleted': 11 } } }) mock_squash_counts.assert_called_once_with()