コード例 #1
0
ファイル: tests.py プロジェクト: bitlinellc/ureport
    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()
コード例 #2
0
ファイル: tests.py プロジェクト: rapidpro/ureport
    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()
コード例 #3
0
ファイル: tests.py プロジェクト: Ilhasoft/ureport
    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()
コード例 #4
0
ファイル: tests.py プロジェクト: fesp21/ureport
    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}
            })
コード例 #5
0
    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()
コード例 #6
0
ファイル: tests.py プロジェクト: Assaye/ureport
    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()
コード例 #7
0
ファイル: tests.py プロジェクト: UNICEFIndia/ureport
    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()